{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Python для Анализа Данных\n",
    "\n",
    "# Лекция 7: Обработка данных с Pandas II\n",
    "\n",
    "**Автор** Полина Полунина\n",
    "\n",
    "**tg:** @ppolunina"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "На прошлом занятии мы работали с винным датасетом, подгрузим его:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "data = pd.read_csv('dpo_1-2_winemag-data_first150k.csv', index_col=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 222,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>description</th>\n",
       "      <th>designation</th>\n",
       "      <th>points</th>\n",
       "      <th>price</th>\n",
       "      <th>province</th>\n",
       "      <th>region_1</th>\n",
       "      <th>region_2</th>\n",
       "      <th>variety</th>\n",
       "      <th>winery</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>US</td>\n",
       "      <td>This tremendous 100% varietal wine hails from ...</td>\n",
       "      <td>Martha's Vineyard</td>\n",
       "      <td>96</td>\n",
       "      <td>235.0</td>\n",
       "      <td>California</td>\n",
       "      <td>Napa Valley</td>\n",
       "      <td>Napa</td>\n",
       "      <td>Cabernet Sauvignon</td>\n",
       "      <td>Heitz</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Spain</td>\n",
       "      <td>Ripe aromas of fig, blackberry and cassis are ...</td>\n",
       "      <td>Carodorum Selección Especial Reserva</td>\n",
       "      <td>96</td>\n",
       "      <td>110.0</td>\n",
       "      <td>Northern Spain</td>\n",
       "      <td>Toro</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Tinta de Toro</td>\n",
       "      <td>Bodega Carmen Rodríguez</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>US</td>\n",
       "      <td>Mac Watson honors the memory of a wine once ma...</td>\n",
       "      <td>Special Selected Late Harvest</td>\n",
       "      <td>96</td>\n",
       "      <td>90.0</td>\n",
       "      <td>California</td>\n",
       "      <td>Knights Valley</td>\n",
       "      <td>Sonoma</td>\n",
       "      <td>Sauvignon Blanc</td>\n",
       "      <td>Macauley</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>US</td>\n",
       "      <td>This spent 20 months in 30% new French oak, an...</td>\n",
       "      <td>Reserve</td>\n",
       "      <td>96</td>\n",
       "      <td>65.0</td>\n",
       "      <td>Oregon</td>\n",
       "      <td>Willamette Valley</td>\n",
       "      <td>Willamette Valley</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Ponzi</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>France</td>\n",
       "      <td>This is the top wine from La Bégude, named aft...</td>\n",
       "      <td>La Brûlade</td>\n",
       "      <td>95</td>\n",
       "      <td>66.0</td>\n",
       "      <td>Provence</td>\n",
       "      <td>Bandol</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Provence red blend</td>\n",
       "      <td>Domaine de la Bégude</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Spain</td>\n",
       "      <td>Deep, dense and pure from the opening bell, th...</td>\n",
       "      <td>Numanthia</td>\n",
       "      <td>95</td>\n",
       "      <td>73.0</td>\n",
       "      <td>Northern Spain</td>\n",
       "      <td>Toro</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Tinta de Toro</td>\n",
       "      <td>Numanthia</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Spain</td>\n",
       "      <td>Slightly gritty black-fruit aromas include a s...</td>\n",
       "      <td>San Román</td>\n",
       "      <td>95</td>\n",
       "      <td>65.0</td>\n",
       "      <td>Northern Spain</td>\n",
       "      <td>Toro</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Tinta de Toro</td>\n",
       "      <td>Maurodos</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Spain</td>\n",
       "      <td>Lush cedary black-fruit aromas are luxe and of...</td>\n",
       "      <td>Carodorum Único Crianza</td>\n",
       "      <td>95</td>\n",
       "      <td>110.0</td>\n",
       "      <td>Northern Spain</td>\n",
       "      <td>Toro</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Tinta de Toro</td>\n",
       "      <td>Bodega Carmen Rodríguez</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>US</td>\n",
       "      <td>This re-named vineyard was formerly bottled as...</td>\n",
       "      <td>Silice</td>\n",
       "      <td>95</td>\n",
       "      <td>65.0</td>\n",
       "      <td>Oregon</td>\n",
       "      <td>Chehalem Mountains</td>\n",
       "      <td>Willamette Valley</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Bergström</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>US</td>\n",
       "      <td>The producer sources from two blocks of the vi...</td>\n",
       "      <td>Gap's Crown Vineyard</td>\n",
       "      <td>95</td>\n",
       "      <td>60.0</td>\n",
       "      <td>California</td>\n",
       "      <td>Sonoma Coast</td>\n",
       "      <td>Sonoma</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Blue Farm</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Italy</td>\n",
       "      <td>Elegance, complexity and structure come togeth...</td>\n",
       "      <td>Ronco della Chiesa</td>\n",
       "      <td>95</td>\n",
       "      <td>80.0</td>\n",
       "      <td>Northeastern Italy</td>\n",
       "      <td>Collio</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Friulano</td>\n",
       "      <td>Borgo del Tiglio</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>US</td>\n",
       "      <td>From 18-year-old vines, this supple well-balan...</td>\n",
       "      <td>Estate Vineyard Wadensvil Block</td>\n",
       "      <td>95</td>\n",
       "      <td>48.0</td>\n",
       "      <td>Oregon</td>\n",
       "      <td>Ribbon Ridge</td>\n",
       "      <td>Willamette Valley</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Patricia Green Cellars</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>US</td>\n",
       "      <td>A standout even in this terrific lineup of 201...</td>\n",
       "      <td>Weber Vineyard</td>\n",
       "      <td>95</td>\n",
       "      <td>48.0</td>\n",
       "      <td>Oregon</td>\n",
       "      <td>Dundee Hills</td>\n",
       "      <td>Willamette Valley</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Patricia Green Cellars</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>France</td>\n",
       "      <td>This wine is in peak condition. The tannins an...</td>\n",
       "      <td>Château Montus Prestige</td>\n",
       "      <td>95</td>\n",
       "      <td>90.0</td>\n",
       "      <td>Southwest France</td>\n",
       "      <td>Madiran</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Tannat</td>\n",
       "      <td>Vignobles Brumont</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>US</td>\n",
       "      <td>With its sophisticated mix of mineral, acid an...</td>\n",
       "      <td>Grace Vineyard</td>\n",
       "      <td>95</td>\n",
       "      <td>185.0</td>\n",
       "      <td>Oregon</td>\n",
       "      <td>Dundee Hills</td>\n",
       "      <td>Willamette Valley</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Domaine Serene</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>US</td>\n",
       "      <td>First made in 2006, this succulent luscious Ch...</td>\n",
       "      <td>Sigrid</td>\n",
       "      <td>95</td>\n",
       "      <td>90.0</td>\n",
       "      <td>Oregon</td>\n",
       "      <td>Willamette Valley</td>\n",
       "      <td>Willamette Valley</td>\n",
       "      <td>Chardonnay</td>\n",
       "      <td>Bergström</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>US</td>\n",
       "      <td>This blockbuster, powerhouse of a wine suggest...</td>\n",
       "      <td>Rainin Vineyard</td>\n",
       "      <td>95</td>\n",
       "      <td>325.0</td>\n",
       "      <td>California</td>\n",
       "      <td>Diamond Mountain District</td>\n",
       "      <td>Napa</td>\n",
       "      <td>Cabernet Sauvignon</td>\n",
       "      <td>Hall</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>Spain</td>\n",
       "      <td>Nicely oaked blackberry, licorice, vanilla and...</td>\n",
       "      <td>6 Años Reserva Premium</td>\n",
       "      <td>95</td>\n",
       "      <td>80.0</td>\n",
       "      <td>Northern Spain</td>\n",
       "      <td>Ribera del Duero</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Tempranillo</td>\n",
       "      <td>Valduero</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>France</td>\n",
       "      <td>Coming from a seven-acre vineyard named after ...</td>\n",
       "      <td>Le Pigeonnier</td>\n",
       "      <td>95</td>\n",
       "      <td>290.0</td>\n",
       "      <td>Southwest France</td>\n",
       "      <td>Cahors</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Malbec</td>\n",
       "      <td>Château Lagrézette</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>US</td>\n",
       "      <td>This fresh and lively medium-bodied wine is be...</td>\n",
       "      <td>Gap's Crown Vineyard</td>\n",
       "      <td>95</td>\n",
       "      <td>75.0</td>\n",
       "      <td>California</td>\n",
       "      <td>Sonoma Coast</td>\n",
       "      <td>Sonoma</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Gary Farrell</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>US</td>\n",
       "      <td>Heitz has made this stellar rosé from the rare...</td>\n",
       "      <td>Grignolino</td>\n",
       "      <td>95</td>\n",
       "      <td>24.0</td>\n",
       "      <td>California</td>\n",
       "      <td>Napa Valley</td>\n",
       "      <td>Napa</td>\n",
       "      <td>Rosé</td>\n",
       "      <td>Heitz</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>Spain</td>\n",
       "      <td>Alluring, complex and powerful aromas of grill...</td>\n",
       "      <td>Prado Enea Gran Reserva</td>\n",
       "      <td>95</td>\n",
       "      <td>79.0</td>\n",
       "      <td>Northern Spain</td>\n",
       "      <td>Rioja</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Tempranillo Blend</td>\n",
       "      <td>Muga</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>Spain</td>\n",
       "      <td>Tarry blackberry and cheesy oak aromas are app...</td>\n",
       "      <td>Termanthia</td>\n",
       "      <td>95</td>\n",
       "      <td>220.0</td>\n",
       "      <td>Northern Spain</td>\n",
       "      <td>Toro</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Tinta de Toro</td>\n",
       "      <td>Numanthia</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>US</td>\n",
       "      <td>The apogee of this ambitious winery's white wi...</td>\n",
       "      <td>Giallo Solare</td>\n",
       "      <td>95</td>\n",
       "      <td>60.0</td>\n",
       "      <td>California</td>\n",
       "      <td>Edna Valley</td>\n",
       "      <td>Central Coast</td>\n",
       "      <td>Chardonnay</td>\n",
       "      <td>Center of Effort</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>US</td>\n",
       "      <td>San Jose-based producer Adam Comartin heads 1,...</td>\n",
       "      <td>R-Bar-R Ranch</td>\n",
       "      <td>95</td>\n",
       "      <td>45.0</td>\n",
       "      <td>California</td>\n",
       "      <td>Santa Cruz Mountains</td>\n",
       "      <td>Central Coast</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Comartin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>New Zealand</td>\n",
       "      <td>Yields were down in 2015, but intensity is up,...</td>\n",
       "      <td>Maté's Vineyard</td>\n",
       "      <td>94</td>\n",
       "      <td>57.0</td>\n",
       "      <td>Kumeu</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Chardonnay</td>\n",
       "      <td>Kumeu River</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>US</td>\n",
       "      <td>Bergström has made a Shea designate since 2003...</td>\n",
       "      <td>Shea Vineyard</td>\n",
       "      <td>94</td>\n",
       "      <td>62.0</td>\n",
       "      <td>Oregon</td>\n",
       "      <td>Willamette Valley</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Bergström</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>US</td>\n",
       "      <td>Focused and dense, this intense wine captures ...</td>\n",
       "      <td>Abetina</td>\n",
       "      <td>94</td>\n",
       "      <td>105.0</td>\n",
       "      <td>Oregon</td>\n",
       "      <td>Willamette Valley</td>\n",
       "      <td>Willamette Valley</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Ponzi</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>US</td>\n",
       "      <td>Cranberry, baked rhubarb, anise and crushed sl...</td>\n",
       "      <td>Garys' Vineyard</td>\n",
       "      <td>94</td>\n",
       "      <td>60.0</td>\n",
       "      <td>California</td>\n",
       "      <td>Santa Lucia Highlands</td>\n",
       "      <td>Central Coast</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Roar</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>US</td>\n",
       "      <td>This standout Rocks District wine brings earth...</td>\n",
       "      <td>The Funk Estate</td>\n",
       "      <td>94</td>\n",
       "      <td>60.0</td>\n",
       "      <td>Washington</td>\n",
       "      <td>Walla Walla Valley (WA)</td>\n",
       "      <td>Columbia Valley</td>\n",
       "      <td>Syrah</td>\n",
       "      <td>Saviah</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150900</th>\n",
       "      <td>Chile</td>\n",
       "      <td>Aromas of freshly cut lumber, complete with so...</td>\n",
       "      <td>Prima Reserva</td>\n",
       "      <td>81</td>\n",
       "      <td>13.0</td>\n",
       "      <td>Maipo Valley</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Cabernet Sauvignon</td>\n",
       "      <td>De Martino</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150901</th>\n",
       "      <td>Chile</td>\n",
       "      <td>Lavishly oaked, the fruit here struggles to ma...</td>\n",
       "      <td>Reserva</td>\n",
       "      <td>81</td>\n",
       "      <td>12.0</td>\n",
       "      <td>Maipo Valley</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Merlot</td>\n",
       "      <td>Undurraga</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150902</th>\n",
       "      <td>Chile</td>\n",
       "      <td>This medium weight Chardonnay offered aromas o...</td>\n",
       "      <td>Estate Bottled</td>\n",
       "      <td>81</td>\n",
       "      <td>10.0</td>\n",
       "      <td>Maipo Valley</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Chardonnay</td>\n",
       "      <td>De Martino</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150903</th>\n",
       "      <td>Chile</td>\n",
       "      <td>Very light berry and mint aromas open this aus...</td>\n",
       "      <td>120</td>\n",
       "      <td>81</td>\n",
       "      <td>7.0</td>\n",
       "      <td>Rapel Valley</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Cabernet Sauvignon</td>\n",
       "      <td>Santa Rita</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150904</th>\n",
       "      <td>Chile</td>\n",
       "      <td>A lot of Chilean Cabernets seem to have a dist...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>81</td>\n",
       "      <td>10.0</td>\n",
       "      <td>Maipo Valley</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Cabernet Sauvignon</td>\n",
       "      <td>De Martino</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150905</th>\n",
       "      <td>Chile</td>\n",
       "      <td>There's not much point in making a reserve-sty...</td>\n",
       "      <td>Prima Reserva</td>\n",
       "      <td>80</td>\n",
       "      <td>13.0</td>\n",
       "      <td>Maipo Valley</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Merlot</td>\n",
       "      <td>De Martino</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150906</th>\n",
       "      <td>France</td>\n",
       "      <td>This lovely wine, a Monopole, is already showi...</td>\n",
       "      <td>Clos des Reas</td>\n",
       "      <td>93</td>\n",
       "      <td>65.0</td>\n",
       "      <td>Burgundy</td>\n",
       "      <td>Vosne-Romanée</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Michel Gros</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150907</th>\n",
       "      <td>France</td>\n",
       "      <td>Rion holds back on the new oak, letting the pu...</td>\n",
       "      <td>Les Beaux-Monts</td>\n",
       "      <td>92</td>\n",
       "      <td>52.0</td>\n",
       "      <td>Burgundy</td>\n",
       "      <td>Vosne-Romanée</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Daniel Rion</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150908</th>\n",
       "      <td>France</td>\n",
       "      <td>Another premier cru from Michel Gros, this one...</td>\n",
       "      <td>Aux Brulees</td>\n",
       "      <td>90</td>\n",
       "      <td>65.0</td>\n",
       "      <td>Burgundy</td>\n",
       "      <td>Vosne-Romanée</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Michel Gros</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150909</th>\n",
       "      <td>France</td>\n",
       "      <td>This is a lovely, fragrant Burgundy, with a sm...</td>\n",
       "      <td>Clos dea Argillieres</td>\n",
       "      <td>89</td>\n",
       "      <td>52.0</td>\n",
       "      <td>Burgundy</td>\n",
       "      <td>Nuits-St.-Georges</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Daniel Rion</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150910</th>\n",
       "      <td>France</td>\n",
       "      <td>Scents of graham cracker and malted milk choco...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>89</td>\n",
       "      <td>38.0</td>\n",
       "      <td>Burgundy</td>\n",
       "      <td>Chambolle-Musigny</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Michel Gros</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150911</th>\n",
       "      <td>France</td>\n",
       "      <td>This needs a good bit of breathing time, then ...</td>\n",
       "      <td>Les Chaliots</td>\n",
       "      <td>87</td>\n",
       "      <td>37.0</td>\n",
       "      <td>Burgundy</td>\n",
       "      <td>Nuits-St.-Georges</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Michel Gros</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150912</th>\n",
       "      <td>France</td>\n",
       "      <td>The nose is dominated by the attractive scents...</td>\n",
       "      <td>Les Charmes</td>\n",
       "      <td>87</td>\n",
       "      <td>65.0</td>\n",
       "      <td>Burgundy</td>\n",
       "      <td>Chambolle-Musigny</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Pinot Noir</td>\n",
       "      <td>Daniel Rion</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150913</th>\n",
       "      <td>France</td>\n",
       "      <td>Inky and rustic, yet in a refined manner. This...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>94</td>\n",
       "      <td>30.0</td>\n",
       "      <td>Rhône Valley</td>\n",
       "      <td>Châteauneuf-du-Pape</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Rhône-style Red Blend</td>\n",
       "      <td>Le Vieux Donjon</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150914</th>\n",
       "      <td>US</td>\n",
       "      <td>Old-gold in color, and thick and syrupy. The a...</td>\n",
       "      <td>Late Harvest Cluster Select</td>\n",
       "      <td>94</td>\n",
       "      <td>25.0</td>\n",
       "      <td>California</td>\n",
       "      <td>Anderson Valley</td>\n",
       "      <td>Mendocino/Lake Counties</td>\n",
       "      <td>White Riesling</td>\n",
       "      <td>Navarro</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150915</th>\n",
       "      <td>US</td>\n",
       "      <td>Decades ago, Beringer’s then-winemaker Myron N...</td>\n",
       "      <td>Nightingale</td>\n",
       "      <td>93</td>\n",
       "      <td>30.0</td>\n",
       "      <td>California</td>\n",
       "      <td>North Coast</td>\n",
       "      <td>North Coast</td>\n",
       "      <td>White Blend</td>\n",
       "      <td>Beringer</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150916</th>\n",
       "      <td>US</td>\n",
       "      <td>An impressive wine that presents a full bouque...</td>\n",
       "      <td>J. Schram</td>\n",
       "      <td>93</td>\n",
       "      <td>65.0</td>\n",
       "      <td>California</td>\n",
       "      <td>Napa Valley</td>\n",
       "      <td>Napa</td>\n",
       "      <td>Champagne Blend</td>\n",
       "      <td>Schramsberg</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150917</th>\n",
       "      <td>France</td>\n",
       "      <td>Light and elegant, this spicy, lively wine is ...</td>\n",
       "      <td>Brut Mosaïque</td>\n",
       "      <td>92</td>\n",
       "      <td>30.0</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Champagne Blend</td>\n",
       "      <td>Jacquart</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150918</th>\n",
       "      <td>France</td>\n",
       "      <td>Jacquart makes a full-bodied, ripe style of Ch...</td>\n",
       "      <td>Cuvée Mosaïque</td>\n",
       "      <td>92</td>\n",
       "      <td>38.0</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Champagne Blend</td>\n",
       "      <td>Jacquart</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150919</th>\n",
       "      <td>France</td>\n",
       "      <td>This classy example opens with a very floral n...</td>\n",
       "      <td>Cuvée President</td>\n",
       "      <td>91</td>\n",
       "      <td>37.0</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Champagne Blend</td>\n",
       "      <td>H.Germain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150920</th>\n",
       "      <td>Italy</td>\n",
       "      <td>Rich and mature aromas of smoke, earth and her...</td>\n",
       "      <td>Brut Riserva</td>\n",
       "      <td>91</td>\n",
       "      <td>19.0</td>\n",
       "      <td>Northeastern Italy</td>\n",
       "      <td>Trento</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Champagne Blend</td>\n",
       "      <td>Letrari</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150921</th>\n",
       "      <td>France</td>\n",
       "      <td>Shows some older notes: a bouquet of toasted w...</td>\n",
       "      <td>Blanc de Blancs Brut Mosaïque</td>\n",
       "      <td>91</td>\n",
       "      <td>38.0</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Champagne Blend</td>\n",
       "      <td>Jacquart</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150922</th>\n",
       "      <td>Italy</td>\n",
       "      <td>Made by 30-ish Roberta Borghese high above Man...</td>\n",
       "      <td>Superiore</td>\n",
       "      <td>91</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Northeastern Italy</td>\n",
       "      <td>Colli Orientali del Friuli</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Tocai</td>\n",
       "      <td>Ronchi di Manzano</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150923</th>\n",
       "      <td>France</td>\n",
       "      <td>Rich and toasty, with tiny bubbles. The bouque...</td>\n",
       "      <td>Demi-Sec</td>\n",
       "      <td>91</td>\n",
       "      <td>30.0</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Champagne Blend</td>\n",
       "      <td>Jacquart</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150924</th>\n",
       "      <td>France</td>\n",
       "      <td>Really fine for a low-acid vintage, there's an...</td>\n",
       "      <td>Diamant Bleu</td>\n",
       "      <td>91</td>\n",
       "      <td>70.0</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Champagne Blend</td>\n",
       "      <td>Heidsieck &amp; Co Monopole</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150925</th>\n",
       "      <td>Italy</td>\n",
       "      <td>Many people feel Fiano represents southern Ita...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>91</td>\n",
       "      <td>20.0</td>\n",
       "      <td>Southern Italy</td>\n",
       "      <td>Fiano di Avellino</td>\n",
       "      <td>NaN</td>\n",
       "      <td>White Blend</td>\n",
       "      <td>Feudi di San Gregorio</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150926</th>\n",
       "      <td>France</td>\n",
       "      <td>Offers an intriguing nose with ginger, lime an...</td>\n",
       "      <td>Cuvée Prestige</td>\n",
       "      <td>91</td>\n",
       "      <td>27.0</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Champagne Blend</td>\n",
       "      <td>H.Germain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150927</th>\n",
       "      <td>Italy</td>\n",
       "      <td>This classic example comes from a cru vineyard...</td>\n",
       "      <td>Terre di Dora</td>\n",
       "      <td>91</td>\n",
       "      <td>20.0</td>\n",
       "      <td>Southern Italy</td>\n",
       "      <td>Fiano di Avellino</td>\n",
       "      <td>NaN</td>\n",
       "      <td>White Blend</td>\n",
       "      <td>Terredora</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150928</th>\n",
       "      <td>France</td>\n",
       "      <td>A perfect salmon shade, with scents of peaches...</td>\n",
       "      <td>Grand Brut Rosé</td>\n",
       "      <td>90</td>\n",
       "      <td>52.0</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>Champagne</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Champagne Blend</td>\n",
       "      <td>Gosset</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150929</th>\n",
       "      <td>Italy</td>\n",
       "      <td>More Pinot Grigios should taste like this. A r...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>90</td>\n",
       "      <td>15.0</td>\n",
       "      <td>Northeastern Italy</td>\n",
       "      <td>Alto Adige</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Pinot Grigio</td>\n",
       "      <td>Alois Lageder</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>150930 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            country                                        description  \\\n",
       "0                US  This tremendous 100% varietal wine hails from ...   \n",
       "1             Spain  Ripe aromas of fig, blackberry and cassis are ...   \n",
       "2                US  Mac Watson honors the memory of a wine once ma...   \n",
       "3                US  This spent 20 months in 30% new French oak, an...   \n",
       "4            France  This is the top wine from La Bégude, named aft...   \n",
       "5             Spain  Deep, dense and pure from the opening bell, th...   \n",
       "6             Spain  Slightly gritty black-fruit aromas include a s...   \n",
       "7             Spain  Lush cedary black-fruit aromas are luxe and of...   \n",
       "8                US  This re-named vineyard was formerly bottled as...   \n",
       "9                US  The producer sources from two blocks of the vi...   \n",
       "10            Italy  Elegance, complexity and structure come togeth...   \n",
       "11               US  From 18-year-old vines, this supple well-balan...   \n",
       "12               US  A standout even in this terrific lineup of 201...   \n",
       "13           France  This wine is in peak condition. The tannins an...   \n",
       "14               US  With its sophisticated mix of mineral, acid an...   \n",
       "15               US  First made in 2006, this succulent luscious Ch...   \n",
       "16               US  This blockbuster, powerhouse of a wine suggest...   \n",
       "17            Spain  Nicely oaked blackberry, licorice, vanilla and...   \n",
       "18           France  Coming from a seven-acre vineyard named after ...   \n",
       "19               US  This fresh and lively medium-bodied wine is be...   \n",
       "20               US  Heitz has made this stellar rosé from the rare...   \n",
       "21            Spain  Alluring, complex and powerful aromas of grill...   \n",
       "22            Spain  Tarry blackberry and cheesy oak aromas are app...   \n",
       "23               US  The apogee of this ambitious winery's white wi...   \n",
       "24               US  San Jose-based producer Adam Comartin heads 1,...   \n",
       "25      New Zealand  Yields were down in 2015, but intensity is up,...   \n",
       "26               US  Bergström has made a Shea designate since 2003...   \n",
       "27               US  Focused and dense, this intense wine captures ...   \n",
       "28               US  Cranberry, baked rhubarb, anise and crushed sl...   \n",
       "29               US  This standout Rocks District wine brings earth...   \n",
       "...             ...                                                ...   \n",
       "150900        Chile  Aromas of freshly cut lumber, complete with so...   \n",
       "150901        Chile  Lavishly oaked, the fruit here struggles to ma...   \n",
       "150902        Chile  This medium weight Chardonnay offered aromas o...   \n",
       "150903        Chile  Very light berry and mint aromas open this aus...   \n",
       "150904        Chile  A lot of Chilean Cabernets seem to have a dist...   \n",
       "150905        Chile  There's not much point in making a reserve-sty...   \n",
       "150906       France  This lovely wine, a Monopole, is already showi...   \n",
       "150907       France  Rion holds back on the new oak, letting the pu...   \n",
       "150908       France  Another premier cru from Michel Gros, this one...   \n",
       "150909       France  This is a lovely, fragrant Burgundy, with a sm...   \n",
       "150910       France  Scents of graham cracker and malted milk choco...   \n",
       "150911       France  This needs a good bit of breathing time, then ...   \n",
       "150912       France  The nose is dominated by the attractive scents...   \n",
       "150913       France  Inky and rustic, yet in a refined manner. This...   \n",
       "150914           US  Old-gold in color, and thick and syrupy. The a...   \n",
       "150915           US  Decades ago, Beringer’s then-winemaker Myron N...   \n",
       "150916           US  An impressive wine that presents a full bouque...   \n",
       "150917       France  Light and elegant, this spicy, lively wine is ...   \n",
       "150918       France  Jacquart makes a full-bodied, ripe style of Ch...   \n",
       "150919       France  This classy example opens with a very floral n...   \n",
       "150920        Italy  Rich and mature aromas of smoke, earth and her...   \n",
       "150921       France  Shows some older notes: a bouquet of toasted w...   \n",
       "150922        Italy  Made by 30-ish Roberta Borghese high above Man...   \n",
       "150923       France  Rich and toasty, with tiny bubbles. The bouque...   \n",
       "150924       France  Really fine for a low-acid vintage, there's an...   \n",
       "150925        Italy  Many people feel Fiano represents southern Ita...   \n",
       "150926       France  Offers an intriguing nose with ginger, lime an...   \n",
       "150927        Italy  This classic example comes from a cru vineyard...   \n",
       "150928       France  A perfect salmon shade, with scents of peaches...   \n",
       "150929        Italy  More Pinot Grigios should taste like this. A r...   \n",
       "\n",
       "                                 designation  points  price  \\\n",
       "0                          Martha's Vineyard      96  235.0   \n",
       "1       Carodorum Selección Especial Reserva      96  110.0   \n",
       "2              Special Selected Late Harvest      96   90.0   \n",
       "3                                    Reserve      96   65.0   \n",
       "4                                 La Brûlade      95   66.0   \n",
       "5                                  Numanthia      95   73.0   \n",
       "6                                  San Román      95   65.0   \n",
       "7                    Carodorum Único Crianza      95  110.0   \n",
       "8                                     Silice      95   65.0   \n",
       "9                       Gap's Crown Vineyard      95   60.0   \n",
       "10                        Ronco della Chiesa      95   80.0   \n",
       "11           Estate Vineyard Wadensvil Block      95   48.0   \n",
       "12                            Weber Vineyard      95   48.0   \n",
       "13                   Château Montus Prestige      95   90.0   \n",
       "14                            Grace Vineyard      95  185.0   \n",
       "15                                    Sigrid      95   90.0   \n",
       "16                           Rainin Vineyard      95  325.0   \n",
       "17                    6 Años Reserva Premium      95   80.0   \n",
       "18                             Le Pigeonnier      95  290.0   \n",
       "19                      Gap's Crown Vineyard      95   75.0   \n",
       "20                                Grignolino      95   24.0   \n",
       "21                   Prado Enea Gran Reserva      95   79.0   \n",
       "22                                Termanthia      95  220.0   \n",
       "23                             Giallo Solare      95   60.0   \n",
       "24                             R-Bar-R Ranch      95   45.0   \n",
       "25                           Maté's Vineyard      94   57.0   \n",
       "26                             Shea Vineyard      94   62.0   \n",
       "27                                   Abetina      94  105.0   \n",
       "28                           Garys' Vineyard      94   60.0   \n",
       "29                           The Funk Estate      94   60.0   \n",
       "...                                      ...     ...    ...   \n",
       "150900                         Prima Reserva      81   13.0   \n",
       "150901                               Reserva      81   12.0   \n",
       "150902                        Estate Bottled      81   10.0   \n",
       "150903                                   120      81    7.0   \n",
       "150904                                   NaN      81   10.0   \n",
       "150905                         Prima Reserva      80   13.0   \n",
       "150906                         Clos des Reas      93   65.0   \n",
       "150907                       Les Beaux-Monts      92   52.0   \n",
       "150908                           Aux Brulees      90   65.0   \n",
       "150909                  Clos dea Argillieres      89   52.0   \n",
       "150910                                   NaN      89   38.0   \n",
       "150911                          Les Chaliots      87   37.0   \n",
       "150912                           Les Charmes      87   65.0   \n",
       "150913                                   NaN      94   30.0   \n",
       "150914           Late Harvest Cluster Select      94   25.0   \n",
       "150915                           Nightingale      93   30.0   \n",
       "150916                             J. Schram      93   65.0   \n",
       "150917                         Brut Mosaïque      92   30.0   \n",
       "150918                        Cuvée Mosaïque      92   38.0   \n",
       "150919                       Cuvée President      91   37.0   \n",
       "150920                          Brut Riserva      91   19.0   \n",
       "150921         Blanc de Blancs Brut Mosaïque      91   38.0   \n",
       "150922                             Superiore      91    NaN   \n",
       "150923                              Demi-Sec      91   30.0   \n",
       "150924                          Diamant Bleu      91   70.0   \n",
       "150925                                   NaN      91   20.0   \n",
       "150926                        Cuvée Prestige      91   27.0   \n",
       "150927                         Terre di Dora      91   20.0   \n",
       "150928                       Grand Brut Rosé      90   52.0   \n",
       "150929                                   NaN      90   15.0   \n",
       "\n",
       "                  province                    region_1  \\\n",
       "0               California                 Napa Valley   \n",
       "1           Northern Spain                        Toro   \n",
       "2               California              Knights Valley   \n",
       "3                   Oregon           Willamette Valley   \n",
       "4                 Provence                      Bandol   \n",
       "5           Northern Spain                        Toro   \n",
       "6           Northern Spain                        Toro   \n",
       "7           Northern Spain                        Toro   \n",
       "8                   Oregon          Chehalem Mountains   \n",
       "9               California                Sonoma Coast   \n",
       "10      Northeastern Italy                      Collio   \n",
       "11                  Oregon                Ribbon Ridge   \n",
       "12                  Oregon                Dundee Hills   \n",
       "13        Southwest France                     Madiran   \n",
       "14                  Oregon                Dundee Hills   \n",
       "15                  Oregon           Willamette Valley   \n",
       "16              California   Diamond Mountain District   \n",
       "17          Northern Spain            Ribera del Duero   \n",
       "18        Southwest France                      Cahors   \n",
       "19              California                Sonoma Coast   \n",
       "20              California                 Napa Valley   \n",
       "21          Northern Spain                       Rioja   \n",
       "22          Northern Spain                        Toro   \n",
       "23              California                 Edna Valley   \n",
       "24              California        Santa Cruz Mountains   \n",
       "25                   Kumeu                         NaN   \n",
       "26                  Oregon           Willamette Valley   \n",
       "27                  Oregon           Willamette Valley   \n",
       "28              California       Santa Lucia Highlands   \n",
       "29              Washington     Walla Walla Valley (WA)   \n",
       "...                    ...                         ...   \n",
       "150900        Maipo Valley                         NaN   \n",
       "150901        Maipo Valley                         NaN   \n",
       "150902        Maipo Valley                         NaN   \n",
       "150903        Rapel Valley                         NaN   \n",
       "150904        Maipo Valley                         NaN   \n",
       "150905        Maipo Valley                         NaN   \n",
       "150906            Burgundy               Vosne-Romanée   \n",
       "150907            Burgundy               Vosne-Romanée   \n",
       "150908            Burgundy               Vosne-Romanée   \n",
       "150909            Burgundy           Nuits-St.-Georges   \n",
       "150910            Burgundy           Chambolle-Musigny   \n",
       "150911            Burgundy           Nuits-St.-Georges   \n",
       "150912            Burgundy           Chambolle-Musigny   \n",
       "150913        Rhône Valley         Châteauneuf-du-Pape   \n",
       "150914          California             Anderson Valley   \n",
       "150915          California                 North Coast   \n",
       "150916          California                 Napa Valley   \n",
       "150917           Champagne                   Champagne   \n",
       "150918           Champagne                   Champagne   \n",
       "150919           Champagne                   Champagne   \n",
       "150920  Northeastern Italy                      Trento   \n",
       "150921           Champagne                   Champagne   \n",
       "150922  Northeastern Italy  Colli Orientali del Friuli   \n",
       "150923           Champagne                   Champagne   \n",
       "150924           Champagne                   Champagne   \n",
       "150925      Southern Italy           Fiano di Avellino   \n",
       "150926           Champagne                   Champagne   \n",
       "150927      Southern Italy           Fiano di Avellino   \n",
       "150928           Champagne                   Champagne   \n",
       "150929  Northeastern Italy                  Alto Adige   \n",
       "\n",
       "                       region_2                variety  \\\n",
       "0                          Napa     Cabernet Sauvignon   \n",
       "1                           NaN          Tinta de Toro   \n",
       "2                        Sonoma        Sauvignon Blanc   \n",
       "3             Willamette Valley             Pinot Noir   \n",
       "4                           NaN     Provence red blend   \n",
       "5                           NaN          Tinta de Toro   \n",
       "6                           NaN          Tinta de Toro   \n",
       "7                           NaN          Tinta de Toro   \n",
       "8             Willamette Valley             Pinot Noir   \n",
       "9                        Sonoma             Pinot Noir   \n",
       "10                          NaN               Friulano   \n",
       "11            Willamette Valley             Pinot Noir   \n",
       "12            Willamette Valley             Pinot Noir   \n",
       "13                          NaN                 Tannat   \n",
       "14            Willamette Valley             Pinot Noir   \n",
       "15            Willamette Valley             Chardonnay   \n",
       "16                         Napa     Cabernet Sauvignon   \n",
       "17                          NaN            Tempranillo   \n",
       "18                          NaN                 Malbec   \n",
       "19                       Sonoma             Pinot Noir   \n",
       "20                         Napa                   Rosé   \n",
       "21                          NaN      Tempranillo Blend   \n",
       "22                          NaN          Tinta de Toro   \n",
       "23                Central Coast             Chardonnay   \n",
       "24                Central Coast             Pinot Noir   \n",
       "25                          NaN             Chardonnay   \n",
       "26                          NaN             Pinot Noir   \n",
       "27            Willamette Valley             Pinot Noir   \n",
       "28                Central Coast             Pinot Noir   \n",
       "29              Columbia Valley                  Syrah   \n",
       "...                         ...                    ...   \n",
       "150900                      NaN     Cabernet Sauvignon   \n",
       "150901                      NaN                 Merlot   \n",
       "150902                      NaN             Chardonnay   \n",
       "150903                      NaN     Cabernet Sauvignon   \n",
       "150904                      NaN     Cabernet Sauvignon   \n",
       "150905                      NaN                 Merlot   \n",
       "150906                      NaN             Pinot Noir   \n",
       "150907                      NaN             Pinot Noir   \n",
       "150908                      NaN             Pinot Noir   \n",
       "150909                      NaN             Pinot Noir   \n",
       "150910                      NaN             Pinot Noir   \n",
       "150911                      NaN             Pinot Noir   \n",
       "150912                      NaN             Pinot Noir   \n",
       "150913                      NaN  Rhône-style Red Blend   \n",
       "150914  Mendocino/Lake Counties         White Riesling   \n",
       "150915              North Coast            White Blend   \n",
       "150916                     Napa        Champagne Blend   \n",
       "150917                      NaN        Champagne Blend   \n",
       "150918                      NaN        Champagne Blend   \n",
       "150919                      NaN        Champagne Blend   \n",
       "150920                      NaN        Champagne Blend   \n",
       "150921                      NaN        Champagne Blend   \n",
       "150922                      NaN                  Tocai   \n",
       "150923                      NaN        Champagne Blend   \n",
       "150924                      NaN        Champagne Blend   \n",
       "150925                      NaN            White Blend   \n",
       "150926                      NaN        Champagne Blend   \n",
       "150927                      NaN            White Blend   \n",
       "150928                      NaN        Champagne Blend   \n",
       "150929                      NaN           Pinot Grigio   \n",
       "\n",
       "                         winery  \n",
       "0                         Heitz  \n",
       "1       Bodega Carmen Rodríguez  \n",
       "2                      Macauley  \n",
       "3                         Ponzi  \n",
       "4          Domaine de la Bégude  \n",
       "5                     Numanthia  \n",
       "6                      Maurodos  \n",
       "7       Bodega Carmen Rodríguez  \n",
       "8                     Bergström  \n",
       "9                     Blue Farm  \n",
       "10             Borgo del Tiglio  \n",
       "11       Patricia Green Cellars  \n",
       "12       Patricia Green Cellars  \n",
       "13            Vignobles Brumont  \n",
       "14               Domaine Serene  \n",
       "15                    Bergström  \n",
       "16                         Hall  \n",
       "17                     Valduero  \n",
       "18           Château Lagrézette  \n",
       "19                 Gary Farrell  \n",
       "20                        Heitz  \n",
       "21                         Muga  \n",
       "22                    Numanthia  \n",
       "23             Center of Effort  \n",
       "24                     Comartin  \n",
       "25                  Kumeu River  \n",
       "26                    Bergström  \n",
       "27                        Ponzi  \n",
       "28                         Roar  \n",
       "29                       Saviah  \n",
       "...                         ...  \n",
       "150900               De Martino  \n",
       "150901                Undurraga  \n",
       "150902               De Martino  \n",
       "150903               Santa Rita  \n",
       "150904               De Martino  \n",
       "150905               De Martino  \n",
       "150906              Michel Gros  \n",
       "150907              Daniel Rion  \n",
       "150908              Michel Gros  \n",
       "150909              Daniel Rion  \n",
       "150910              Michel Gros  \n",
       "150911              Michel Gros  \n",
       "150912              Daniel Rion  \n",
       "150913          Le Vieux Donjon  \n",
       "150914                  Navarro  \n",
       "150915                 Beringer  \n",
       "150916              Schramsberg  \n",
       "150917                 Jacquart  \n",
       "150918                 Jacquart  \n",
       "150919                H.Germain  \n",
       "150920                  Letrari  \n",
       "150921                 Jacquart  \n",
       "150922        Ronchi di Manzano  \n",
       "150923                 Jacquart  \n",
       "150924  Heidsieck & Co Monopole  \n",
       "150925    Feudi di San Gregorio  \n",
       "150926                H.Germain  \n",
       "150927                Terredora  \n",
       "150928                   Gosset  \n",
       "150929            Alois Lageder  \n",
       "\n",
       "[150930 rows x 10 columns]"
      ]
     },
     "execution_count": 222,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Groupby"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Groupby - это очень важный и широко используемый метод. Позволяет делать группировку данных по какому-либо столбцу. \n",
    "\n",
    "Пример:\n",
    "* посчитать средние баллы и цену в разрезе по странам и провинциям"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>points</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Albania</th>\n",
       "      <td>88.000000</td>\n",
       "      <td>20.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Argentina</th>\n",
       "      <td>85.996093</td>\n",
       "      <td>20.794881</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Australia</th>\n",
       "      <td>87.892475</td>\n",
       "      <td>31.258480</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Austria</th>\n",
       "      <td>89.276742</td>\n",
       "      <td>31.192106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Bosnia and Herzegovina</th>\n",
       "      <td>84.750000</td>\n",
       "      <td>12.750000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                           points      price\n",
       "country                                     \n",
       "Albania                 88.000000  20.000000\n",
       "Argentina               85.996093  20.794881\n",
       "Australia               87.892475  31.258480\n",
       "Austria                 89.276742  31.192106\n",
       "Bosnia and Herzegovina  84.750000  12.750000"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = data.groupby(['country']).mean()\n",
    "df.head()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 220,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>points</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>South Korea</th>\n",
       "      <td>81.500000</td>\n",
       "      <td>13.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Montenegro</th>\n",
       "      <td>82.000000</td>\n",
       "      <td>10.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>China</th>\n",
       "      <td>82.000000</td>\n",
       "      <td>20.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Brazil</th>\n",
       "      <td>83.240000</td>\n",
       "      <td>19.920000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Slovakia</th>\n",
       "      <td>83.666667</td>\n",
       "      <td>15.333333</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                points      price\n",
       "country                          \n",
       "South Korea  81.500000  13.500000\n",
       "Montenegro   82.000000  10.000000\n",
       "China        82.000000  20.333333\n",
       "Brazil       83.240000  19.920000\n",
       "Slovakia     83.666667  15.333333"
      ]
     },
     "execution_count": 220,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# сортировка по столбцу points\n",
    "df.sort_values('points', ascending=True).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>points</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>country</th>\n",
       "      <th>winery</th>\n",
       "      <th>region_1</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">Argentina</th>\n",
       "      <th>1919</th>\n",
       "      <th>Mendoza</th>\n",
       "      <td>83.0</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2 Copas</th>\n",
       "      <th>Mendoza</th>\n",
       "      <td>81.0</td>\n",
       "      <td>8.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25 Lagunas</th>\n",
       "      <th>San Juan</th>\n",
       "      <td>81.0</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">Achaval-Ferrer</th>\n",
       "      <th>La Consulta</th>\n",
       "      <td>91.5</td>\n",
       "      <td>112.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Luján de Cuyo</th>\n",
       "      <td>92.5</td>\n",
       "      <td>140.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                        points  price\n",
       "country   winery         region_1                    \n",
       "Argentina 1919           Mendoza          83.0   10.0\n",
       "          2 Copas        Mendoza          81.0    8.0\n",
       "          25 Lagunas     San Juan         81.0   10.0\n",
       "          Achaval-Ferrer La Consulta      91.5  112.0\n",
       "                         Luján de Cuyo    92.5  140.0"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.groupby(['country', 'winery', 'region_1']).mean().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data[data.country == 'US'].mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Join\n",
    "\n",
    "Join - позволяет объединять несколько таблиц в единую витрину по ключам (одинаковым столбцам). \n",
    "\n",
    "Join бывает разный:\n",
    "\n",
    "<img src=\"06_join.png\" style=\"height:300px\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Посмотрим на примерах как это работает:\n",
    "\n",
    "Допустим, у нас есть две таблички\n",
    "* первая содержит информацию о студентах и айдишниках курсов, которые они посещают\n",
    "* вторая - таблица с описанием курсов"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>subject_id</th>\n",
       "      <th>first_name</th>\n",
       "      <th>last_name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100500</td>\n",
       "      <td>Настя</td>\n",
       "      <td>Андреева</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>200600</td>\n",
       "      <td>Катя</td>\n",
       "      <td>Котикова</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>100500</td>\n",
       "      <td>Света</td>\n",
       "      <td>Иванова</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>300700</td>\n",
       "      <td>Карина</td>\n",
       "      <td>Данилова</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>200600</td>\n",
       "      <td>Вася</td>\n",
       "      <td>Пупкин</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>500900</td>\n",
       "      <td>Данила</td>\n",
       "      <td>Собачкин</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  subject_id first_name last_name\n",
       "0     100500      Настя  Андреева\n",
       "1     200600       Катя  Котикова\n",
       "2     100500      Света   Иванова\n",
       "3     300700     Карина  Данилова\n",
       "4     200600       Вася    Пупкин\n",
       "5     500900     Данила  Собачкин"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "# создаем таблицу 1\n",
    "data_1 = np.array([['100500', '200600', '100500', '300700', '200600', '500900'],\n",
    "                   ['Настя', 'Катя', 'Света', 'Карина', 'Вася', 'Данила'], \n",
    "                   ['Андреева', 'Котикова', 'Иванова', 'Данилова', 'Пупкин', 'Собачкин']])\n",
    "\n",
    "names = pd.DataFrame(data_1.T, columns = ['subject_id', 'first_name', 'last_name'])\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>subject_id</th>\n",
       "      <th>course_name</th>\n",
       "      <th>description</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100500</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>200600</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>300700</td>\n",
       "      <td>Анализ данных</td>\n",
       "      <td>краткий курс для чайников</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>400700</td>\n",
       "      <td>Мат. анализ</td>\n",
       "      <td>многомерный анализ</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  subject_id       course_name                                   description\n",
       "0     100500        Математика  продвинутые методы математической статистики\n",
       "1     200600  Программирование                       расширенный курс по с++\n",
       "2     300700     Анализ данных                     краткий курс для чайников\n",
       "3     400700       Мат. анализ                            многомерный анализ"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# создаем таблицу 2\n",
    "data_2 = np.array([['100500', '200600', '300700', '400700'],\n",
    "                   ['Математика', 'Программирование', 'Анализ данных', 'Мат. анализ'], \n",
    "                   ['продвинутые методы математической статистики', 'расширенный курс по с++',\\\n",
    "                            'краткий курс для чайников', 'многомерный анализ']])\n",
    "subjects = pd.DataFrame(data_2.T, columns = ['subject_id','course_name', 'description'])\n",
    "subjects"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Делаем Join:\n",
    "\n",
    "Left Join"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>subject_id</th>\n",
       "      <th>first_name</th>\n",
       "      <th>last_name</th>\n",
       "      <th>course_name</th>\n",
       "      <th>description</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100500</td>\n",
       "      <td>Настя</td>\n",
       "      <td>Андреева</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>200600</td>\n",
       "      <td>Катя</td>\n",
       "      <td>Котикова</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>100500</td>\n",
       "      <td>Света</td>\n",
       "      <td>Иванова</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>300700</td>\n",
       "      <td>Карина</td>\n",
       "      <td>Данилова</td>\n",
       "      <td>Анализ данных</td>\n",
       "      <td>краткий курс для чайников</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>200600</td>\n",
       "      <td>Вася</td>\n",
       "      <td>Пупкин</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>500900</td>\n",
       "      <td>Данила</td>\n",
       "      <td>Собачкин</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  subject_id first_name last_name       course_name  \\\n",
       "0     100500      Настя  Андреева        Математика   \n",
       "1     200600       Катя  Котикова  Программирование   \n",
       "2     100500      Света   Иванова        Математика   \n",
       "3     300700     Карина  Данилова     Анализ данных   \n",
       "4     200600       Вася    Пупкин  Программирование   \n",
       "5     500900     Данила  Собачкин               NaN   \n",
       "\n",
       "                                    description  \n",
       "0  продвинутые методы математической статистики  \n",
       "1                       расширенный курс по с++  \n",
       "2  продвинутые методы математической статистики  \n",
       "3                     краткий курс для чайников  \n",
       "4                       расширенный курс по с++  \n",
       "5                                           NaN  "
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.merge(subjects, on='subject_id', how='left')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Inner Join"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>subject_id</th>\n",
       "      <th>first_name</th>\n",
       "      <th>last_name</th>\n",
       "      <th>course_name</th>\n",
       "      <th>description</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100500</td>\n",
       "      <td>Настя</td>\n",
       "      <td>Андреева</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100500</td>\n",
       "      <td>Света</td>\n",
       "      <td>Иванова</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>200600</td>\n",
       "      <td>Катя</td>\n",
       "      <td>Котикова</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>200600</td>\n",
       "      <td>Вася</td>\n",
       "      <td>Пупкин</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>300700</td>\n",
       "      <td>Карина</td>\n",
       "      <td>Данилова</td>\n",
       "      <td>Анализ данных</td>\n",
       "      <td>краткий курс для чайников</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  subject_id first_name last_name       course_name  \\\n",
       "0     100500      Настя  Андреева        Математика   \n",
       "1     100500      Света   Иванова        Математика   \n",
       "2     200600       Катя  Котикова  Программирование   \n",
       "3     200600       Вася    Пупкин  Программирование   \n",
       "4     300700     Карина  Данилова     Анализ данных   \n",
       "\n",
       "                                    description  \n",
       "0  продвинутые методы математической статистики  \n",
       "1  продвинутые методы математической статистики  \n",
       "2                       расширенный курс по с++  \n",
       "3                       расширенный курс по с++  \n",
       "4                     краткий курс для чайников  "
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.merge(subjects, on='subject_id', how='inner')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Right Join"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>subject_id</th>\n",
       "      <th>first_name</th>\n",
       "      <th>last_name</th>\n",
       "      <th>course_name</th>\n",
       "      <th>description</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100500</td>\n",
       "      <td>Настя</td>\n",
       "      <td>Андреева</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100500</td>\n",
       "      <td>Света</td>\n",
       "      <td>Иванова</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>200600</td>\n",
       "      <td>Катя</td>\n",
       "      <td>Котикова</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>200600</td>\n",
       "      <td>Вася</td>\n",
       "      <td>Пупкин</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>300700</td>\n",
       "      <td>Карина</td>\n",
       "      <td>Данилова</td>\n",
       "      <td>Анализ данных</td>\n",
       "      <td>краткий курс для чайников</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>400700</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Мат. анализ</td>\n",
       "      <td>многомерный анализ</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  subject_id first_name last_name       course_name  \\\n",
       "0     100500      Настя  Андреева        Математика   \n",
       "1     100500      Света   Иванова        Математика   \n",
       "2     200600       Катя  Котикова  Программирование   \n",
       "3     200600       Вася    Пупкин  Программирование   \n",
       "4     300700     Карина  Данилова     Анализ данных   \n",
       "5     400700        NaN       NaN       Мат. анализ   \n",
       "\n",
       "                                    description  \n",
       "0  продвинутые методы математической статистики  \n",
       "1  продвинутые методы математической статистики  \n",
       "2                       расширенный курс по с++  \n",
       "3                       расширенный курс по с++  \n",
       "4                     краткий курс для чайников  \n",
       "5                            многомерный анализ  "
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.merge(subjects, on='subject_id', how='right')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Outer Join"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>subject_id</th>\n",
       "      <th>first_name</th>\n",
       "      <th>last_name</th>\n",
       "      <th>course_name</th>\n",
       "      <th>description</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100500</td>\n",
       "      <td>Настя</td>\n",
       "      <td>Андреева</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100500</td>\n",
       "      <td>Света</td>\n",
       "      <td>Иванова</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>200600</td>\n",
       "      <td>Катя</td>\n",
       "      <td>Котикова</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>200600</td>\n",
       "      <td>Вася</td>\n",
       "      <td>Пупкин</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>300700</td>\n",
       "      <td>Карина</td>\n",
       "      <td>Данилова</td>\n",
       "      <td>Анализ данных</td>\n",
       "      <td>краткий курс для чайников</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>500900</td>\n",
       "      <td>Данила</td>\n",
       "      <td>Собачкин</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>400700</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Мат. анализ</td>\n",
       "      <td>многомерный анализ</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  subject_id first_name last_name       course_name  \\\n",
       "0     100500      Настя  Андреева        Математика   \n",
       "1     100500      Света   Иванова        Математика   \n",
       "2     200600       Катя  Котикова  Программирование   \n",
       "3     200600       Вася    Пупкин  Программирование   \n",
       "4     300700     Карина  Данилова     Анализ данных   \n",
       "5     500900     Данила  Собачкин               NaN   \n",
       "6     400700        NaN       NaN       Мат. анализ   \n",
       "\n",
       "                                    description  \n",
       "0  продвинутые методы математической статистики  \n",
       "1  продвинутые методы математической статистики  \n",
       "2                       расширенный курс по с++  \n",
       "3                       расширенный курс по с++  \n",
       "4                     краткий курс для чайников  \n",
       "5                                           NaN  \n",
       "6                            многомерный анализ  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = names.merge(subjects, on=['subject_id'], how='outer')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>subject_id</th>\n",
       "      <th>first_name</th>\n",
       "      <th>last_name</th>\n",
       "      <th>course_name</th>\n",
       "      <th>description</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100500</td>\n",
       "      <td>Настя</td>\n",
       "      <td>Андреева</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100500</td>\n",
       "      <td>Света</td>\n",
       "      <td>Иванова</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>200600</td>\n",
       "      <td>Катя</td>\n",
       "      <td>Котикова</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>200600</td>\n",
       "      <td>Вася</td>\n",
       "      <td>Пупкин</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>300700</td>\n",
       "      <td>Карина</td>\n",
       "      <td>Данилова</td>\n",
       "      <td>Анализ данных</td>\n",
       "      <td>краткий курс для чайников</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>500900</td>\n",
       "      <td>Данила</td>\n",
       "      <td>Собачкин</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>400700</td>\n",
       "      <td>kotiki</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Мат. анализ</td>\n",
       "      <td>многомерный анализ</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  subject_id first_name last_name       course_name  \\\n",
       "0     100500      Настя  Андреева        Математика   \n",
       "1     100500      Света   Иванова        Математика   \n",
       "2     200600       Катя  Котикова  Программирование   \n",
       "3     200600       Вася    Пупкин  Программирование   \n",
       "4     300700     Карина  Данилова     Анализ данных   \n",
       "5     500900     Данила  Собачкин               NaN   \n",
       "6     400700     kotiki       NaN       Мат. анализ   \n",
       "\n",
       "                                    description  \n",
       "0  продвинутые методы математической статистики  \n",
       "1  продвинутые методы математической статистики  \n",
       "2                       расширенный курс по с++  \n",
       "3                       расширенный курс по с++  \n",
       "4                     краткий курс для чайников  \n",
       "5                                           NaN  \n",
       "6                            многомерный анализ  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.first_name = df.first_name.fillna('kotiki')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>subject_id</th>\n",
       "      <th>first_name</th>\n",
       "      <th>last_name</th>\n",
       "      <th>course_name</th>\n",
       "      <th>description</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100500</td>\n",
       "      <td>Настя</td>\n",
       "      <td>Андреева</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100500</td>\n",
       "      <td>Света</td>\n",
       "      <td>Иванова</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>200600</td>\n",
       "      <td>Катя</td>\n",
       "      <td>Котикова</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>200600</td>\n",
       "      <td>Вася</td>\n",
       "      <td>Пупкин</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>300700</td>\n",
       "      <td>Карина</td>\n",
       "      <td>Данилова</td>\n",
       "      <td>Анализ данных</td>\n",
       "      <td>краткий курс для чайников</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>500900</td>\n",
       "      <td>Данила</td>\n",
       "      <td>Собачкин</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>400700</td>\n",
       "      <td>kotiki</td>\n",
       "      <td>pesiki</td>\n",
       "      <td>Мат. анализ</td>\n",
       "      <td>многомерный анализ</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  subject_id first_name last_name       course_name  \\\n",
       "0     100500      Настя  Андреева        Математика   \n",
       "1     100500      Света   Иванова        Математика   \n",
       "2     200600       Катя  Котикова  Программирование   \n",
       "3     200600       Вася    Пупкин  Программирование   \n",
       "4     300700     Карина  Данилова     Анализ данных   \n",
       "5     500900     Данила  Собачкин               NaN   \n",
       "6     400700     kotiki    pesiki       Мат. анализ   \n",
       "\n",
       "                                    description  \n",
       "0  продвинутые методы математической статистики  \n",
       "1  продвинутые методы математической статистики  \n",
       "2                       расширенный курс по с++  \n",
       "3                       расширенный курс по с++  \n",
       "4                     краткий курс для чайников  \n",
       "5                                           NaN  \n",
       "6                            многомерный анализ  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "df.last_name = df.last_name.fillna('pesiki')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>subject_id</th>\n",
       "      <th>first_name</th>\n",
       "      <th>last_name</th>\n",
       "      <th>course_name</th>\n",
       "      <th>description</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100500</td>\n",
       "      <td>Настя</td>\n",
       "      <td>Андреева</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100500</td>\n",
       "      <td>Света</td>\n",
       "      <td>Иванова</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>200600</td>\n",
       "      <td>Катя</td>\n",
       "      <td>Котикова</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>200600</td>\n",
       "      <td>Вася</td>\n",
       "      <td>Пупкин</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>300700</td>\n",
       "      <td>Карина</td>\n",
       "      <td>Данилова</td>\n",
       "      <td>Анализ данных</td>\n",
       "      <td>краткий курс для чайников</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>500900</td>\n",
       "      <td>Данила</td>\n",
       "      <td>Собачкин</td>\n",
       "      <td>cлоники</td>\n",
       "      <td>котята</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>400700</td>\n",
       "      <td>котики</td>\n",
       "      <td>щеночки</td>\n",
       "      <td>Мат. анализ</td>\n",
       "      <td>многомерный анализ</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  subject_id first_name last_name       course_name  \\\n",
       "0     100500      Настя  Андреева        Математика   \n",
       "1     100500      Света   Иванова        Математика   \n",
       "2     200600       Катя  Котикова  Программирование   \n",
       "3     200600       Вася    Пупкин  Программирование   \n",
       "4     300700     Карина  Данилова     Анализ данных   \n",
       "5     500900     Данила  Собачкин           cлоники   \n",
       "6     400700     котики   щеночки       Мат. анализ   \n",
       "\n",
       "                                    description  \n",
       "0  продвинутые методы математической статистики  \n",
       "1  продвинутые методы математической статистики  \n",
       "2                       расширенный курс по с++  \n",
       "3                       расширенный курс по с++  \n",
       "4                     краткий курс для чайников  \n",
       "5                                        котята  \n",
       "6                            многомерный анализ  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val = [1, 'котики', 'щеночки', 'cлоники', 'котята']\n",
    "col = df.columns.tolist()\n",
    "\n",
    "for i in range(df.shape[1]):\n",
    "    df[col[i]] = df[col[i]].fillna(val[i])\n",
    "    \n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.merge(names, subjects, left_on = 'column_1', котятаright_on = 'Column_1', how='inner')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## DateTime index\n",
    "\n",
    "DateTime Index - это особый тип индекса в pandas, предназначенный для работы с временными рядами. Давайте познакомимся с ним поближе. Для этой цели мы подгрузим известный стандартный датасет \"Occupancy Detection Data Set\", он содержит следующие данные:\n",
    "* date time year-month-day hour : minute : second \n",
    "* Temperature, in Celsius \n",
    "* Relative Humidity, % \n",
    "* Light, in Lux \n",
    "* CO2, in ppm \n",
    "* Humidity Ratio, Derived quantity from temperature and relative humidity, in kgwater-vapor/kg-air \n",
    "* Occupancy, 0 or 1, 0 for not occupied, 1 for occupied status"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2015-02-04 17:51:00</td>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2015-02-04 17:51:59</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2675</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.00</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2015-02-04 17:53:00</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2450</td>\n",
       "      <td>426.0</td>\n",
       "      <td>713.50</td>\n",
       "      <td>0.004779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2015-02-04 17:54:00</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>708.25</td>\n",
       "      <td>0.004772</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2015-02-04 17:55:00</td>\n",
       "      <td>23.10</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>704.50</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  date  Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "1  2015-02-04 17:51:00        23.18   27.2720  426.0  721.25       0.004793   \n",
       "2  2015-02-04 17:51:59        23.15   27.2675  429.5  714.00       0.004783   \n",
       "3  2015-02-04 17:53:00        23.15   27.2450  426.0  713.50       0.004779   \n",
       "4  2015-02-04 17:54:00        23.15   27.2000  426.0  708.25       0.004772   \n",
       "5  2015-02-04 17:55:00        23.10   27.2000  426.0  704.50       0.004757   \n",
       "\n",
       "   Occupancy  \n",
       "1          1  \n",
       "2          1  \n",
       "3          1  \n",
       "4          1  \n",
       "5          1  "
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv('occupancy_data/datatraining.txt')\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2015-02-04 17:51:00</td>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2015-02-04 17:51:59</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2675</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.00</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  date  Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "1  2015-02-04 17:51:00        23.18   27.2720  426.0  721.25       0.004793   \n",
       "2  2015-02-04 17:51:59        23.15   27.2675  429.5  714.00       0.004783   \n",
       "\n",
       "   Occupancy  \n",
       "1          1  \n",
       "2          1  "
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = data.iloc[0:2, :].copy()\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2015-02-04 17:51:00</td>\n",
       "      <td>100500.00</td>\n",
       "      <td>10500.0000</td>\n",
       "      <td>100500.0</td>\n",
       "      <td>100500.0</td>\n",
       "      <td>100500.000000</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2015-02-04 17:51:59</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2675</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.0</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  date  Temperature    Humidity     Light       CO2  \\\n",
       "1  2015-02-04 17:51:00    100500.00  10500.0000  100500.0  100500.0   \n",
       "2  2015-02-04 17:51:59        23.15     27.2675     429.5     714.0   \n",
       "\n",
       "   HumidityRatio  Occupancy  \n",
       "1  100500.000000          1  \n",
       "2       0.004783          1  "
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[0, 1:] = [100500, 10500, 100500, 100500, 100500, 1]\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2015-02-04 17:51:00</td>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2015-02-04 17:51:59</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2675</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.00</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2015-02-04 17:53:00</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2450</td>\n",
       "      <td>426.0</td>\n",
       "      <td>713.50</td>\n",
       "      <td>0.004779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2015-02-04 17:54:00</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>708.25</td>\n",
       "      <td>0.004772</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2015-02-04 17:55:00</td>\n",
       "      <td>23.10</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>704.50</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  date  Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "1  2015-02-04 17:51:00        23.18   27.2720  426.0  721.25       0.004793   \n",
       "2  2015-02-04 17:51:59        23.15   27.2675  429.5  714.00       0.004783   \n",
       "3  2015-02-04 17:53:00        23.15   27.2450  426.0  713.50       0.004779   \n",
       "4  2015-02-04 17:54:00        23.15   27.2000  426.0  708.25       0.004772   \n",
       "5  2015-02-04 17:55:00        23.10   27.2000  426.0  704.50       0.004757   \n",
       "\n",
       "   Occupancy  \n",
       "1          1  \n",
       "2          1  \n",
       "3          1  \n",
       "4          1  \n",
       "5          1  "
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dff = data.head()\n",
    "dff"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.concat([dff, df], axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>2015-02-04 17:51:00</td>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>2015-02-04 17:51:59</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2675</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.00</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>2015-02-04 17:53:00</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2450</td>\n",
       "      <td>426.0</td>\n",
       "      <td>713.50</td>\n",
       "      <td>0.004779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>2015-02-04 17:54:00</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>708.25</td>\n",
       "      <td>0.004772</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>2015-02-04 17:55:00</td>\n",
       "      <td>23.10</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>704.50</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>2015-02-04 17:51:00</td>\n",
       "      <td>100500.00</td>\n",
       "      <td>10500.0000</td>\n",
       "      <td>100500.0</td>\n",
       "      <td>100500.00</td>\n",
       "      <td>100500.000000</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>2015-02-04 17:51:59</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2675</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.00</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                    date  Temperature    Humidity     Light  \\\n",
       "date                                                                          \n",
       "2015-02-04 17:51:00  2015-02-04 17:51:00        23.18     27.2720     426.0   \n",
       "2015-02-04 17:51:59  2015-02-04 17:51:59        23.15     27.2675     429.5   \n",
       "2015-02-04 17:53:00  2015-02-04 17:53:00        23.15     27.2450     426.0   \n",
       "2015-02-04 17:54:00  2015-02-04 17:54:00        23.15     27.2000     426.0   \n",
       "2015-02-04 17:55:00  2015-02-04 17:55:00        23.10     27.2000     426.0   \n",
       "2015-02-04 17:51:00  2015-02-04 17:51:00    100500.00  10500.0000  100500.0   \n",
       "2015-02-04 17:51:59  2015-02-04 17:51:59        23.15     27.2675     429.5   \n",
       "\n",
       "                           CO2  HumidityRatio  Occupancy  \n",
       "date                                                      \n",
       "2015-02-04 17:51:00     721.25       0.004793          1  \n",
       "2015-02-04 17:51:59     714.00       0.004783          1  \n",
       "2015-02-04 17:53:00     713.50       0.004779          1  \n",
       "2015-02-04 17:54:00     708.25       0.004772          1  \n",
       "2015-02-04 17:55:00     704.50       0.004757          1  \n",
       "2015-02-04 17:51:00  100500.00  100500.000000          1  \n",
       "2015-02-04 17:51:59     714.00       0.004783          1  "
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index = pd.to_datetime(df.date)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Давайте превратим колонку с датой в datetime index:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2675</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.00</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2450</td>\n",
       "      <td>426.0</td>\n",
       "      <td>713.50</td>\n",
       "      <td>0.004779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>708.25</td>\n",
       "      <td>0.004772</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>23.10</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>704.50</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "date                                                                       \n",
       "2015-02-04 17:51:00        23.18   27.2720  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:59        23.15   27.2675  429.5  714.00       0.004783   \n",
       "2015-02-04 17:53:00        23.15   27.2450  426.0  713.50       0.004779   \n",
       "2015-02-04 17:54:00        23.15   27.2000  426.0  708.25       0.004772   \n",
       "2015-02-04 17:55:00        23.10   27.2000  426.0  704.50       0.004757   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00          1  \n",
       "2015-02-04 17:51:59          1  \n",
       "2015-02-04 17:53:00          1  \n",
       "2015-02-04 17:54:00          1  \n",
       "2015-02-04 17:55:00          1  "
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.index = pd.to_datetime(data.date)\n",
    "data.drop('date', axis=1, inplace=True)\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Замечательно! А зачем мы так старались? \n",
    "\n",
    "Давайте посмотрим, что можно делать с данными, имеющими временной индекс."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1. Подвыборки"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2015-02-04 17:51:00', '2015-02-04 17:51:59',\n",
       "               '2015-02-04 17:53:00', '2015-02-04 17:54:00',\n",
       "               '2015-02-04 17:55:00', '2015-02-04 17:55:59',\n",
       "               '2015-02-04 17:57:00', '2015-02-04 17:57:59',\n",
       "               '2015-02-04 17:58:59', '2015-02-04 18:00:00',\n",
       "               ...\n",
       "               '2015-02-10 09:23:59', '2015-02-10 09:24:59',\n",
       "               '2015-02-10 09:26:00', '2015-02-10 09:27:00',\n",
       "               '2015-02-10 09:28:00', '2015-02-10 09:29:00',\n",
       "               '2015-02-10 09:29:59', '2015-02-10 09:30:59',\n",
       "               '2015-02-10 09:32:00', '2015-02-10 09:33:00'],\n",
       "              dtype='datetime64[ns]', name='date', length=8143, freq=None)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2675</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.00</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2450</td>\n",
       "      <td>426.0</td>\n",
       "      <td>713.50</td>\n",
       "      <td>0.004779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>708.25</td>\n",
       "      <td>0.004772</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>23.10</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>704.50</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "date                                                                       \n",
       "2015-02-04 17:51:00        23.18   27.2720  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:59        23.15   27.2675  429.5  714.00       0.004783   \n",
       "2015-02-04 17:53:00        23.15   27.2450  426.0  713.50       0.004779   \n",
       "2015-02-04 17:54:00        23.15   27.2000  426.0  708.25       0.004772   \n",
       "2015-02-04 17:55:00        23.10   27.2000  426.0  704.50       0.004757   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00          1  \n",
       "2015-02-04 17:51:59          1  \n",
       "2015-02-04 17:53:00          1  \n",
       "2015-02-04 17:54:00          1  \n",
       "2015-02-04 17:55:00          1  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[data.index.month == 2].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-06 13:00:00</th>\n",
       "      <td>21.600000</td>\n",
       "      <td>20.000000</td>\n",
       "      <td>53.000000</td>\n",
       "      <td>739.25</td>\n",
       "      <td>0.003185</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-06 13:01:00</th>\n",
       "      <td>21.533333</td>\n",
       "      <td>19.963333</td>\n",
       "      <td>58.333333</td>\n",
       "      <td>732.00</td>\n",
       "      <td>0.003166</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-06 13:01:59</th>\n",
       "      <td>21.550000</td>\n",
       "      <td>20.000000</td>\n",
       "      <td>61.500000</td>\n",
       "      <td>733.00</td>\n",
       "      <td>0.003175</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-06 13:02:59</th>\n",
       "      <td>21.525000</td>\n",
       "      <td>20.000000</td>\n",
       "      <td>48.500000</td>\n",
       "      <td>723.50</td>\n",
       "      <td>0.003170</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-06 13:04:00</th>\n",
       "      <td>21.500000</td>\n",
       "      <td>19.972500</td>\n",
       "      <td>62.500000</td>\n",
       "      <td>720.25</td>\n",
       "      <td>0.003161</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature   Humidity      Light     CO2  HumidityRatio  \\\n",
       "date                                                                            \n",
       "2015-02-06 13:00:00    21.600000  20.000000  53.000000  739.25       0.003185   \n",
       "2015-02-06 13:01:00    21.533333  19.963333  58.333333  732.00       0.003166   \n",
       "2015-02-06 13:01:59    21.550000  20.000000  61.500000  733.00       0.003175   \n",
       "2015-02-06 13:02:59    21.525000  20.000000  48.500000  723.50       0.003170   \n",
       "2015-02-06 13:04:00    21.500000  19.972500  62.500000  720.25       0.003161   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-06 13:00:00          0  \n",
       "2015-02-06 13:01:00          0  \n",
       "2015-02-06 13:01:59          0  \n",
       "2015-02-06 13:02:59          0  \n",
       "2015-02-06 13:04:00          0  "
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[(data.index.day == 6) & (data.index.hour == 13)].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-08 00:00:00</th>\n",
       "      <td>19.6</td>\n",
       "      <td>29.390000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>438.500000</td>\n",
       "      <td>0.004143</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-08 00:01:00</th>\n",
       "      <td>19.6</td>\n",
       "      <td>29.463333</td>\n",
       "      <td>0.0</td>\n",
       "      <td>438.666667</td>\n",
       "      <td>0.004154</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-08 00:02:00</th>\n",
       "      <td>19.6</td>\n",
       "      <td>29.500000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>437.500000</td>\n",
       "      <td>0.004159</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-08 00:03:00</th>\n",
       "      <td>19.6</td>\n",
       "      <td>29.445000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>437.000000</td>\n",
       "      <td>0.004151</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-08 00:04:00</th>\n",
       "      <td>19.6</td>\n",
       "      <td>29.500000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>0.004159</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature   Humidity  Light         CO2  HumidityRatio  \\\n",
       "date                                                                            \n",
       "2015-02-08 00:00:00         19.6  29.390000    0.0  438.500000       0.004143   \n",
       "2015-02-08 00:01:00         19.6  29.463333    0.0  438.666667       0.004154   \n",
       "2015-02-08 00:02:00         19.6  29.500000    0.0  437.500000       0.004159   \n",
       "2015-02-08 00:03:00         19.6  29.445000    0.0  437.000000       0.004151   \n",
       "2015-02-08 00:04:00         19.6  29.500000    0.0  440.000000       0.004159   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-08 00:00:00          0  \n",
       "2015-02-08 00:01:00          0  \n",
       "2015-02-08 00:02:00          0  \n",
       "2015-02-08 00:03:00          0  \n",
       "2015-02-08 00:04:00          0  "
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['2015-02-08'].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-08 14:55:00</th>\n",
       "      <td>20.290</td>\n",
       "      <td>26.2</td>\n",
       "      <td>85.666667</td>\n",
       "      <td>418.666667</td>\n",
       "      <td>0.003853</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-08 14:55:59</th>\n",
       "      <td>20.315</td>\n",
       "      <td>26.2</td>\n",
       "      <td>59.250000</td>\n",
       "      <td>422.500000</td>\n",
       "      <td>0.003859</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity      Light         CO2  \\\n",
       "date                                                                \n",
       "2015-02-08 14:55:00       20.290      26.2  85.666667  418.666667   \n",
       "2015-02-08 14:55:59       20.315      26.2  59.250000  422.500000   \n",
       "\n",
       "                     HumidityRatio  Occupancy  \n",
       "date                                           \n",
       "2015-02-08 14:55:00       0.003853          0  \n",
       "2015-02-08 14:55:59       0.003859          0  "
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['2015-02-08 14:55':'2015-02-08 14:56']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.180000</td>\n",
       "      <td>27.272000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.250000</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>23.150000</td>\n",
       "      <td>27.267500</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.000000</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>23.150000</td>\n",
       "      <td>27.245000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>713.500000</td>\n",
       "      <td>0.004779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>23.150000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>708.250000</td>\n",
       "      <td>0.004772</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>23.100000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>704.500000</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:59</th>\n",
       "      <td>23.100000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>701.000000</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:57:00</th>\n",
       "      <td>23.100000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>701.666667</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:57:59</th>\n",
       "      <td>23.100000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>699.000000</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:58:59</th>\n",
       "      <td>23.100000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>689.333333</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:00:00</th>\n",
       "      <td>23.075000</td>\n",
       "      <td>27.175000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>688.000000</td>\n",
       "      <td>0.004745</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:01:00</th>\n",
       "      <td>23.075000</td>\n",
       "      <td>27.150000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>690.250000</td>\n",
       "      <td>0.004741</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:02:00</th>\n",
       "      <td>23.100000</td>\n",
       "      <td>27.100000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>691.000000</td>\n",
       "      <td>0.004739</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:03:00</th>\n",
       "      <td>23.100000</td>\n",
       "      <td>27.166667</td>\n",
       "      <td>419.0</td>\n",
       "      <td>683.500000</td>\n",
       "      <td>0.004751</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:04:00</th>\n",
       "      <td>23.050000</td>\n",
       "      <td>27.150000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>687.500000</td>\n",
       "      <td>0.004734</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:04:59</th>\n",
       "      <td>23.000000</td>\n",
       "      <td>27.125000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>686.000000</td>\n",
       "      <td>0.004715</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:06:00</th>\n",
       "      <td>23.000000</td>\n",
       "      <td>27.125000</td>\n",
       "      <td>418.5</td>\n",
       "      <td>680.500000</td>\n",
       "      <td>0.004715</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:07:00</th>\n",
       "      <td>23.000000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>681.500000</td>\n",
       "      <td>0.004728</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:08:00</th>\n",
       "      <td>22.945000</td>\n",
       "      <td>27.290000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>685.000000</td>\n",
       "      <td>0.004728</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:08:59</th>\n",
       "      <td>22.945000</td>\n",
       "      <td>27.390000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>685.000000</td>\n",
       "      <td>0.004745</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:10:00</th>\n",
       "      <td>22.890000</td>\n",
       "      <td>27.390000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>689.000000</td>\n",
       "      <td>0.004730</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:10:59</th>\n",
       "      <td>22.890000</td>\n",
       "      <td>27.390000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>689.500000</td>\n",
       "      <td>0.004730</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:11:59</th>\n",
       "      <td>22.890000</td>\n",
       "      <td>27.390000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>689.000000</td>\n",
       "      <td>0.004730</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:13:00</th>\n",
       "      <td>22.890000</td>\n",
       "      <td>27.445000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>691.000000</td>\n",
       "      <td>0.004739</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:14:00</th>\n",
       "      <td>22.890000</td>\n",
       "      <td>27.500000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>688.000000</td>\n",
       "      <td>0.004749</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:15:00</th>\n",
       "      <td>22.890000</td>\n",
       "      <td>27.500000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>689.500000</td>\n",
       "      <td>0.004749</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:16:00</th>\n",
       "      <td>22.790000</td>\n",
       "      <td>27.445000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>689.000000</td>\n",
       "      <td>0.004710</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:16:59</th>\n",
       "      <td>22.790000</td>\n",
       "      <td>27.500000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>685.666667</td>\n",
       "      <td>0.004720</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:17:59</th>\n",
       "      <td>22.790000</td>\n",
       "      <td>27.500000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>687.000000</td>\n",
       "      <td>0.004720</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:19:00</th>\n",
       "      <td>22.790000</td>\n",
       "      <td>27.500000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>688.000000</td>\n",
       "      <td>0.004720</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:20:00</th>\n",
       "      <td>22.745000</td>\n",
       "      <td>27.500000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>670.000000</td>\n",
       "      <td>0.004707</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:04:00</th>\n",
       "      <td>20.700000</td>\n",
       "      <td>34.417500</td>\n",
       "      <td>419.0</td>\n",
       "      <td>568.750000</td>\n",
       "      <td>0.005203</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:04:59</th>\n",
       "      <td>20.700000</td>\n",
       "      <td>34.090000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>556.666667</td>\n",
       "      <td>0.005153</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:06:00</th>\n",
       "      <td>20.700000</td>\n",
       "      <td>34.296667</td>\n",
       "      <td>419.0</td>\n",
       "      <td>548.000000</td>\n",
       "      <td>0.005184</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:07:00</th>\n",
       "      <td>20.730000</td>\n",
       "      <td>34.466667</td>\n",
       "      <td>419.0</td>\n",
       "      <td>563.333333</td>\n",
       "      <td>0.005220</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:08:00</th>\n",
       "      <td>20.745000</td>\n",
       "      <td>34.567500</td>\n",
       "      <td>426.0</td>\n",
       "      <td>593.750000</td>\n",
       "      <td>0.005240</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:08:59</th>\n",
       "      <td>20.767500</td>\n",
       "      <td>34.717500</td>\n",
       "      <td>422.5</td>\n",
       "      <td>600.750000</td>\n",
       "      <td>0.005270</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:10:00</th>\n",
       "      <td>20.790000</td>\n",
       "      <td>35.090000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>623.000000</td>\n",
       "      <td>0.005335</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:10:59</th>\n",
       "      <td>20.790000</td>\n",
       "      <td>34.972500</td>\n",
       "      <td>433.0</td>\n",
       "      <td>631.000000</td>\n",
       "      <td>0.005317</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:11:59</th>\n",
       "      <td>20.790000</td>\n",
       "      <td>34.826667</td>\n",
       "      <td>433.0</td>\n",
       "      <td>636.000000</td>\n",
       "      <td>0.005295</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:13:00</th>\n",
       "      <td>20.840000</td>\n",
       "      <td>35.195000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>636.750000</td>\n",
       "      <td>0.005368</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:14:00</th>\n",
       "      <td>20.890000</td>\n",
       "      <td>35.300000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>663.000000</td>\n",
       "      <td>0.005401</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:15:00</th>\n",
       "      <td>20.856667</td>\n",
       "      <td>35.096667</td>\n",
       "      <td>433.0</td>\n",
       "      <td>665.333333</td>\n",
       "      <td>0.005358</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:16:00</th>\n",
       "      <td>20.890000</td>\n",
       "      <td>35.320000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>669.500000</td>\n",
       "      <td>0.005404</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:16:59</th>\n",
       "      <td>20.917500</td>\n",
       "      <td>35.475000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>679.250000</td>\n",
       "      <td>0.005437</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:17:59</th>\n",
       "      <td>20.890000</td>\n",
       "      <td>35.400000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>684.666667</td>\n",
       "      <td>0.005416</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:19:00</th>\n",
       "      <td>20.917500</td>\n",
       "      <td>35.717500</td>\n",
       "      <td>433.0</td>\n",
       "      <td>706.250000</td>\n",
       "      <td>0.005474</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:20:00</th>\n",
       "      <td>20.958750</td>\n",
       "      <td>35.683750</td>\n",
       "      <td>433.0</td>\n",
       "      <td>712.625000</td>\n",
       "      <td>0.005483</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:21:00</th>\n",
       "      <td>21.000000</td>\n",
       "      <td>35.650000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>719.000000</td>\n",
       "      <td>0.005492</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:22:00</th>\n",
       "      <td>21.000000</td>\n",
       "      <td>35.700000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>730.250000</td>\n",
       "      <td>0.005500</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:23:00</th>\n",
       "      <td>21.000000</td>\n",
       "      <td>35.760000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>739.000000</td>\n",
       "      <td>0.005509</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:23:59</th>\n",
       "      <td>21.000000</td>\n",
       "      <td>35.850000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>756.250000</td>\n",
       "      <td>0.005523</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:24:59</th>\n",
       "      <td>21.000000</td>\n",
       "      <td>35.700000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>761.000000</td>\n",
       "      <td>0.005500</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:26:00</th>\n",
       "      <td>21.025000</td>\n",
       "      <td>35.950000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>763.000000</td>\n",
       "      <td>0.005547</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:27:00</th>\n",
       "      <td>21.000000</td>\n",
       "      <td>35.860000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>771.333333</td>\n",
       "      <td>0.005525</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:28:00</th>\n",
       "      <td>21.050000</td>\n",
       "      <td>36.050000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>780.250000</td>\n",
       "      <td>0.005571</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:29:00</th>\n",
       "      <td>21.050000</td>\n",
       "      <td>36.097500</td>\n",
       "      <td>433.0</td>\n",
       "      <td>787.250000</td>\n",
       "      <td>0.005579</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:29:59</th>\n",
       "      <td>21.050000</td>\n",
       "      <td>35.995000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>789.500000</td>\n",
       "      <td>0.005563</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:30:59</th>\n",
       "      <td>21.100000</td>\n",
       "      <td>36.095000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>798.500000</td>\n",
       "      <td>0.005596</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:32:00</th>\n",
       "      <td>21.100000</td>\n",
       "      <td>36.260000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>820.333333</td>\n",
       "      <td>0.005621</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:33:00</th>\n",
       "      <td>21.100000</td>\n",
       "      <td>36.200000</td>\n",
       "      <td>447.0</td>\n",
       "      <td>821.000000</td>\n",
       "      <td>0.005612</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8143 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature   Humidity  Light         CO2  HumidityRatio  \\\n",
       "date                                                                            \n",
       "2015-02-04 17:51:00    23.180000  27.272000  426.0  721.250000       0.004793   \n",
       "2015-02-04 17:51:59    23.150000  27.267500  429.5  714.000000       0.004783   \n",
       "2015-02-04 17:53:00    23.150000  27.245000  426.0  713.500000       0.004779   \n",
       "2015-02-04 17:54:00    23.150000  27.200000  426.0  708.250000       0.004772   \n",
       "2015-02-04 17:55:00    23.100000  27.200000  426.0  704.500000       0.004757   \n",
       "2015-02-04 17:55:59    23.100000  27.200000  419.0  701.000000       0.004757   \n",
       "2015-02-04 17:57:00    23.100000  27.200000  419.0  701.666667       0.004757   \n",
       "2015-02-04 17:57:59    23.100000  27.200000  419.0  699.000000       0.004757   \n",
       "2015-02-04 17:58:59    23.100000  27.200000  419.0  689.333333       0.004757   \n",
       "2015-02-04 18:00:00    23.075000  27.175000  419.0  688.000000       0.004745   \n",
       "2015-02-04 18:01:00    23.075000  27.150000  419.0  690.250000       0.004741   \n",
       "2015-02-04 18:02:00    23.100000  27.100000  419.0  691.000000       0.004739   \n",
       "2015-02-04 18:03:00    23.100000  27.166667  419.0  683.500000       0.004751   \n",
       "2015-02-04 18:04:00    23.050000  27.150000  419.0  687.500000       0.004734   \n",
       "2015-02-04 18:04:59    23.000000  27.125000  419.0  686.000000       0.004715   \n",
       "2015-02-04 18:06:00    23.000000  27.125000  418.5  680.500000       0.004715   \n",
       "2015-02-04 18:07:00    23.000000  27.200000    0.0  681.500000       0.004728   \n",
       "2015-02-04 18:08:00    22.945000  27.290000    0.0  685.000000       0.004728   \n",
       "2015-02-04 18:08:59    22.945000  27.390000    0.0  685.000000       0.004745   \n",
       "2015-02-04 18:10:00    22.890000  27.390000    0.0  689.000000       0.004730   \n",
       "2015-02-04 18:10:59    22.890000  27.390000    0.0  689.500000       0.004730   \n",
       "2015-02-04 18:11:59    22.890000  27.390000    0.0  689.000000       0.004730   \n",
       "2015-02-04 18:13:00    22.890000  27.445000    0.0  691.000000       0.004739   \n",
       "2015-02-04 18:14:00    22.890000  27.500000    0.0  688.000000       0.004749   \n",
       "2015-02-04 18:15:00    22.890000  27.500000    0.0  689.500000       0.004749   \n",
       "2015-02-04 18:16:00    22.790000  27.445000    0.0  689.000000       0.004710   \n",
       "2015-02-04 18:16:59    22.790000  27.500000    0.0  685.666667       0.004720   \n",
       "2015-02-04 18:17:59    22.790000  27.500000    0.0  687.000000       0.004720   \n",
       "2015-02-04 18:19:00    22.790000  27.500000    0.0  688.000000       0.004720   \n",
       "2015-02-04 18:20:00    22.745000  27.500000    0.0  670.000000       0.004707   \n",
       "...                          ...        ...    ...         ...            ...   \n",
       "2015-02-10 09:04:00    20.700000  34.417500  419.0  568.750000       0.005203   \n",
       "2015-02-10 09:04:59    20.700000  34.090000  419.0  556.666667       0.005153   \n",
       "2015-02-10 09:06:00    20.700000  34.296667  419.0  548.000000       0.005184   \n",
       "2015-02-10 09:07:00    20.730000  34.466667  419.0  563.333333       0.005220   \n",
       "2015-02-10 09:08:00    20.745000  34.567500  426.0  593.750000       0.005240   \n",
       "2015-02-10 09:08:59    20.767500  34.717500  422.5  600.750000       0.005270   \n",
       "2015-02-10 09:10:00    20.790000  35.090000  426.0  623.000000       0.005335   \n",
       "2015-02-10 09:10:59    20.790000  34.972500  433.0  631.000000       0.005317   \n",
       "2015-02-10 09:11:59    20.790000  34.826667  433.0  636.000000       0.005295   \n",
       "2015-02-10 09:13:00    20.840000  35.195000  433.0  636.750000       0.005368   \n",
       "2015-02-10 09:14:00    20.890000  35.300000  433.0  663.000000       0.005401   \n",
       "2015-02-10 09:15:00    20.856667  35.096667  433.0  665.333333       0.005358   \n",
       "2015-02-10 09:16:00    20.890000  35.320000  433.0  669.500000       0.005404   \n",
       "2015-02-10 09:16:59    20.917500  35.475000  433.0  679.250000       0.005437   \n",
       "2015-02-10 09:17:59    20.890000  35.400000  433.0  684.666667       0.005416   \n",
       "2015-02-10 09:19:00    20.917500  35.717500  433.0  706.250000       0.005474   \n",
       "2015-02-10 09:20:00    20.958750  35.683750  433.0  712.625000       0.005483   \n",
       "2015-02-10 09:21:00    21.000000  35.650000  433.0  719.000000       0.005492   \n",
       "2015-02-10 09:22:00    21.000000  35.700000  433.0  730.250000       0.005500   \n",
       "2015-02-10 09:23:00    21.000000  35.760000  433.0  739.000000       0.005509   \n",
       "2015-02-10 09:23:59    21.000000  35.850000  433.0  756.250000       0.005523   \n",
       "2015-02-10 09:24:59    21.000000  35.700000  433.0  761.000000       0.005500   \n",
       "2015-02-10 09:26:00    21.025000  35.950000  433.0  763.000000       0.005547   \n",
       "2015-02-10 09:27:00    21.000000  35.860000  433.0  771.333333       0.005525   \n",
       "2015-02-10 09:28:00    21.050000  36.050000  433.0  780.250000       0.005571   \n",
       "2015-02-10 09:29:00    21.050000  36.097500  433.0  787.250000       0.005579   \n",
       "2015-02-10 09:29:59    21.050000  35.995000  433.0  789.500000       0.005563   \n",
       "2015-02-10 09:30:59    21.100000  36.095000  433.0  798.500000       0.005596   \n",
       "2015-02-10 09:32:00    21.100000  36.260000  433.0  820.333333       0.005621   \n",
       "2015-02-10 09:33:00    21.100000  36.200000  447.0  821.000000       0.005612   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00          1  \n",
       "2015-02-04 17:51:59          1  \n",
       "2015-02-04 17:53:00          1  \n",
       "2015-02-04 17:54:00          1  \n",
       "2015-02-04 17:55:00          1  \n",
       "2015-02-04 17:55:59          1  \n",
       "2015-02-04 17:57:00          1  \n",
       "2015-02-04 17:57:59          1  \n",
       "2015-02-04 17:58:59          1  \n",
       "2015-02-04 18:00:00          1  \n",
       "2015-02-04 18:01:00          1  \n",
       "2015-02-04 18:02:00          1  \n",
       "2015-02-04 18:03:00          1  \n",
       "2015-02-04 18:04:00          1  \n",
       "2015-02-04 18:04:59          1  \n",
       "2015-02-04 18:06:00          1  \n",
       "2015-02-04 18:07:00          0  \n",
       "2015-02-04 18:08:00          0  \n",
       "2015-02-04 18:08:59          0  \n",
       "2015-02-04 18:10:00          0  \n",
       "2015-02-04 18:10:59          0  \n",
       "2015-02-04 18:11:59          0  \n",
       "2015-02-04 18:13:00          0  \n",
       "2015-02-04 18:14:00          0  \n",
       "2015-02-04 18:15:00          0  \n",
       "2015-02-04 18:16:00          0  \n",
       "2015-02-04 18:16:59          0  \n",
       "2015-02-04 18:17:59          0  \n",
       "2015-02-04 18:19:00          0  \n",
       "2015-02-04 18:20:00          0  \n",
       "...                        ...  \n",
       "2015-02-10 09:04:00          1  \n",
       "2015-02-10 09:04:59          1  \n",
       "2015-02-10 09:06:00          1  \n",
       "2015-02-10 09:07:00          1  \n",
       "2015-02-10 09:08:00          1  \n",
       "2015-02-10 09:08:59          1  \n",
       "2015-02-10 09:10:00          1  \n",
       "2015-02-10 09:10:59          1  \n",
       "2015-02-10 09:11:59          1  \n",
       "2015-02-10 09:13:00          1  \n",
       "2015-02-10 09:14:00          1  \n",
       "2015-02-10 09:15:00          1  \n",
       "2015-02-10 09:16:00          1  \n",
       "2015-02-10 09:16:59          1  \n",
       "2015-02-10 09:17:59          1  \n",
       "2015-02-10 09:19:00          1  \n",
       "2015-02-10 09:20:00          1  \n",
       "2015-02-10 09:21:00          1  \n",
       "2015-02-10 09:22:00          1  \n",
       "2015-02-10 09:23:00          1  \n",
       "2015-02-10 09:23:59          1  \n",
       "2015-02-10 09:24:59          1  \n",
       "2015-02-10 09:26:00          1  \n",
       "2015-02-10 09:27:00          1  \n",
       "2015-02-10 09:28:00          1  \n",
       "2015-02-10 09:29:00          1  \n",
       "2015-02-10 09:29:59          1  \n",
       "2015-02-10 09:30:59          1  \n",
       "2015-02-10 09:32:00          1  \n",
       "2015-02-10 09:33:00          1  \n",
       "\n",
       "[8143 rows x 6 columns]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. Resampling"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Resampling в данном случае означает передискретизацию данных. Что такое передискретизация? В нашем примере данные представлены в секундном формате. Что делать, если нам нужно другое представление? Например, минутное, ежечасное, ежедневное, еженедельное и т.д.? Можно использовать resampling! \n",
    "\n",
    "Если обощить, всего два возможных случая:\n",
    "* требуется повысить уровень дискретизации, т.е. получить более частую разбивку (например, минутные данные в секундные)\n",
    "* требуется понизить уровень дискретизации, т.е. получить более редкую разбивку (например, минутные данные в десятиминутные, часовые)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Давайте разбираться:\n",
    "\n",
    "#### 1. повышение уровня дискретизации"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:01</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:02</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:03</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:04</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "date                                                                       \n",
       "2015-02-04 17:51:00        23.18    27.272  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:01          NaN       NaN    NaN     NaN            NaN   \n",
       "2015-02-04 17:51:02          NaN       NaN    NaN     NaN            NaN   \n",
       "2015-02-04 17:51:03          NaN       NaN    NaN     NaN            NaN   \n",
       "2015-02-04 17:51:04          NaN       NaN    NaN     NaN            NaN   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00        1.0  \n",
       "2015-02-04 17:51:01        NaN  \n",
       "2015-02-04 17:51:02        NaN  \n",
       "2015-02-04 17:51:03        NaN  \n",
       "2015-02-04 17:51:04        NaN  "
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('S').asfreq().head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Очень много пропусков! Что с ними делать?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Forward fill NaN values in the resampled data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:01</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:02</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:03</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:04</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "date                                                                       \n",
       "2015-02-04 17:51:00        23.18    27.272  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:01        23.18    27.272  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:02        23.18    27.272  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:03        23.18    27.272  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:04        23.18    27.272  426.0  721.25       0.004793   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00          1  \n",
       "2015-02-04 17:51:01          1  \n",
       "2015-02-04 17:51:02          1  \n",
       "2015-02-04 17:51:03          1  \n",
       "2015-02-04 17:51:04          1  "
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('S').pad().head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Backward fill NaN values in the resampled data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2675</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.00</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2450</td>\n",
       "      <td>426.0</td>\n",
       "      <td>713.50</td>\n",
       "      <td>0.004779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>708.25</td>\n",
       "      <td>0.004772</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>23.10</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>704.50</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "date                                                                       \n",
       "2015-02-04 17:51:00        23.18   27.2720  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:59        23.15   27.2675  429.5  714.00       0.004783   \n",
       "2015-02-04 17:53:00        23.15   27.2450  426.0  713.50       0.004779   \n",
       "2015-02-04 17:54:00        23.15   27.2000  426.0  708.25       0.004772   \n",
       "2015-02-04 17:55:00        23.10   27.2000  426.0  704.50       0.004757   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00          1  \n",
       "2015-02-04 17:51:59          1  \n",
       "2015-02-04 17:53:00          1  \n",
       "2015-02-04 17:54:00          1  \n",
       "2015-02-04 17:55:00          1  "
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.18000</td>\n",
       "      <td>27.272000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.250000</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:30</th>\n",
       "      <td>23.15000</td>\n",
       "      <td>27.267500</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.000000</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:52:00</th>\n",
       "      <td>23.15000</td>\n",
       "      <td>27.267500</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.000000</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:52:30</th>\n",
       "      <td>23.15000</td>\n",
       "      <td>27.245000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>713.500000</td>\n",
       "      <td>0.004779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>23.15000</td>\n",
       "      <td>27.245000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>713.500000</td>\n",
       "      <td>0.004779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:30</th>\n",
       "      <td>23.15000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>708.250000</td>\n",
       "      <td>0.004772</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>23.15000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>708.250000</td>\n",
       "      <td>0.004772</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:30</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>704.500000</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>704.500000</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:30</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>701.000000</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:56:00</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>701.000000</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:56:30</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>701.666667</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:57:00</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>701.666667</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:57:30</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>699.000000</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:58:00</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>699.000000</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:58:30</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>689.333333</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:59:00</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>689.333333</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:59:30</th>\n",
       "      <td>23.07500</td>\n",
       "      <td>27.175000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>688.000000</td>\n",
       "      <td>0.004745</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:00:00</th>\n",
       "      <td>23.07500</td>\n",
       "      <td>27.175000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>688.000000</td>\n",
       "      <td>0.004745</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:00:30</th>\n",
       "      <td>23.07500</td>\n",
       "      <td>27.150000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>690.250000</td>\n",
       "      <td>0.004741</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:01:00</th>\n",
       "      <td>23.07500</td>\n",
       "      <td>27.150000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>690.250000</td>\n",
       "      <td>0.004741</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:01:30</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.100000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>691.000000</td>\n",
       "      <td>0.004739</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:02:00</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.100000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>691.000000</td>\n",
       "      <td>0.004739</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:02:30</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.166667</td>\n",
       "      <td>419.0</td>\n",
       "      <td>683.500000</td>\n",
       "      <td>0.004751</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:03:00</th>\n",
       "      <td>23.10000</td>\n",
       "      <td>27.166667</td>\n",
       "      <td>419.0</td>\n",
       "      <td>683.500000</td>\n",
       "      <td>0.004751</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:03:30</th>\n",
       "      <td>23.05000</td>\n",
       "      <td>27.150000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>687.500000</td>\n",
       "      <td>0.004734</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:04:00</th>\n",
       "      <td>23.05000</td>\n",
       "      <td>27.150000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>687.500000</td>\n",
       "      <td>0.004734</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:04:30</th>\n",
       "      <td>23.00000</td>\n",
       "      <td>27.125000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>686.000000</td>\n",
       "      <td>0.004715</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:05:00</th>\n",
       "      <td>23.00000</td>\n",
       "      <td>27.125000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>686.000000</td>\n",
       "      <td>0.004715</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:05:30</th>\n",
       "      <td>23.00000</td>\n",
       "      <td>27.125000</td>\n",
       "      <td>418.5</td>\n",
       "      <td>680.500000</td>\n",
       "      <td>0.004715</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:18:30</th>\n",
       "      <td>20.91750</td>\n",
       "      <td>35.717500</td>\n",
       "      <td>433.0</td>\n",
       "      <td>706.250000</td>\n",
       "      <td>0.005474</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:19:00</th>\n",
       "      <td>20.91750</td>\n",
       "      <td>35.717500</td>\n",
       "      <td>433.0</td>\n",
       "      <td>706.250000</td>\n",
       "      <td>0.005474</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:19:30</th>\n",
       "      <td>20.95875</td>\n",
       "      <td>35.683750</td>\n",
       "      <td>433.0</td>\n",
       "      <td>712.625000</td>\n",
       "      <td>0.005483</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:20:00</th>\n",
       "      <td>20.95875</td>\n",
       "      <td>35.683750</td>\n",
       "      <td>433.0</td>\n",
       "      <td>712.625000</td>\n",
       "      <td>0.005483</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:20:30</th>\n",
       "      <td>21.00000</td>\n",
       "      <td>35.650000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>719.000000</td>\n",
       "      <td>0.005492</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:21:00</th>\n",
       "      <td>21.00000</td>\n",
       "      <td>35.650000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>719.000000</td>\n",
       "      <td>0.005492</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:21:30</th>\n",
       "      <td>21.00000</td>\n",
       "      <td>35.700000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>730.250000</td>\n",
       "      <td>0.005500</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:22:00</th>\n",
       "      <td>21.00000</td>\n",
       "      <td>35.700000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>730.250000</td>\n",
       "      <td>0.005500</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:22:30</th>\n",
       "      <td>21.00000</td>\n",
       "      <td>35.760000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>739.000000</td>\n",
       "      <td>0.005509</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:23:00</th>\n",
       "      <td>21.00000</td>\n",
       "      <td>35.760000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>739.000000</td>\n",
       "      <td>0.005509</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:23:30</th>\n",
       "      <td>21.00000</td>\n",
       "      <td>35.850000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>756.250000</td>\n",
       "      <td>0.005523</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:24:00</th>\n",
       "      <td>21.00000</td>\n",
       "      <td>35.850000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>756.250000</td>\n",
       "      <td>0.005523</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:24:30</th>\n",
       "      <td>21.00000</td>\n",
       "      <td>35.700000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>761.000000</td>\n",
       "      <td>0.005500</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:25:00</th>\n",
       "      <td>21.00000</td>\n",
       "      <td>35.700000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>761.000000</td>\n",
       "      <td>0.005500</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:25:30</th>\n",
       "      <td>21.02500</td>\n",
       "      <td>35.950000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>763.000000</td>\n",
       "      <td>0.005547</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:26:00</th>\n",
       "      <td>21.02500</td>\n",
       "      <td>35.950000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>763.000000</td>\n",
       "      <td>0.005547</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:26:30</th>\n",
       "      <td>21.00000</td>\n",
       "      <td>35.860000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>771.333333</td>\n",
       "      <td>0.005525</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:27:00</th>\n",
       "      <td>21.00000</td>\n",
       "      <td>35.860000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>771.333333</td>\n",
       "      <td>0.005525</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:27:30</th>\n",
       "      <td>21.05000</td>\n",
       "      <td>36.050000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>780.250000</td>\n",
       "      <td>0.005571</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:28:00</th>\n",
       "      <td>21.05000</td>\n",
       "      <td>36.050000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>780.250000</td>\n",
       "      <td>0.005571</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:28:30</th>\n",
       "      <td>21.05000</td>\n",
       "      <td>36.097500</td>\n",
       "      <td>433.0</td>\n",
       "      <td>787.250000</td>\n",
       "      <td>0.005579</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:29:00</th>\n",
       "      <td>21.05000</td>\n",
       "      <td>36.097500</td>\n",
       "      <td>433.0</td>\n",
       "      <td>787.250000</td>\n",
       "      <td>0.005579</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:29:30</th>\n",
       "      <td>21.05000</td>\n",
       "      <td>35.995000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>789.500000</td>\n",
       "      <td>0.005563</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:30:00</th>\n",
       "      <td>21.05000</td>\n",
       "      <td>35.995000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>789.500000</td>\n",
       "      <td>0.005563</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:30:30</th>\n",
       "      <td>21.10000</td>\n",
       "      <td>36.095000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>798.500000</td>\n",
       "      <td>0.005596</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:31:00</th>\n",
       "      <td>21.10000</td>\n",
       "      <td>36.095000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>798.500000</td>\n",
       "      <td>0.005596</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:31:30</th>\n",
       "      <td>21.10000</td>\n",
       "      <td>36.260000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>820.333333</td>\n",
       "      <td>0.005621</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:32:00</th>\n",
       "      <td>21.10000</td>\n",
       "      <td>36.260000</td>\n",
       "      <td>433.0</td>\n",
       "      <td>820.333333</td>\n",
       "      <td>0.005621</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:32:30</th>\n",
       "      <td>21.10000</td>\n",
       "      <td>36.200000</td>\n",
       "      <td>447.0</td>\n",
       "      <td>821.000000</td>\n",
       "      <td>0.005612</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:33:00</th>\n",
       "      <td>21.10000</td>\n",
       "      <td>36.200000</td>\n",
       "      <td>447.0</td>\n",
       "      <td>821.000000</td>\n",
       "      <td>0.005612</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>16285 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature   Humidity  Light         CO2  HumidityRatio  \\\n",
       "date                                                                            \n",
       "2015-02-04 17:51:00     23.18000  27.272000  426.0  721.250000       0.004793   \n",
       "2015-02-04 17:51:30     23.15000  27.267500  429.5  714.000000       0.004783   \n",
       "2015-02-04 17:52:00     23.15000  27.267500  429.5  714.000000       0.004783   \n",
       "2015-02-04 17:52:30     23.15000  27.245000  426.0  713.500000       0.004779   \n",
       "2015-02-04 17:53:00     23.15000  27.245000  426.0  713.500000       0.004779   \n",
       "2015-02-04 17:53:30     23.15000  27.200000  426.0  708.250000       0.004772   \n",
       "2015-02-04 17:54:00     23.15000  27.200000  426.0  708.250000       0.004772   \n",
       "2015-02-04 17:54:30     23.10000  27.200000  426.0  704.500000       0.004757   \n",
       "2015-02-04 17:55:00     23.10000  27.200000  426.0  704.500000       0.004757   \n",
       "2015-02-04 17:55:30     23.10000  27.200000  419.0  701.000000       0.004757   \n",
       "2015-02-04 17:56:00     23.10000  27.200000  419.0  701.000000       0.004757   \n",
       "2015-02-04 17:56:30     23.10000  27.200000  419.0  701.666667       0.004757   \n",
       "2015-02-04 17:57:00     23.10000  27.200000  419.0  701.666667       0.004757   \n",
       "2015-02-04 17:57:30     23.10000  27.200000  419.0  699.000000       0.004757   \n",
       "2015-02-04 17:58:00     23.10000  27.200000  419.0  699.000000       0.004757   \n",
       "2015-02-04 17:58:30     23.10000  27.200000  419.0  689.333333       0.004757   \n",
       "2015-02-04 17:59:00     23.10000  27.200000  419.0  689.333333       0.004757   \n",
       "2015-02-04 17:59:30     23.07500  27.175000  419.0  688.000000       0.004745   \n",
       "2015-02-04 18:00:00     23.07500  27.175000  419.0  688.000000       0.004745   \n",
       "2015-02-04 18:00:30     23.07500  27.150000  419.0  690.250000       0.004741   \n",
       "2015-02-04 18:01:00     23.07500  27.150000  419.0  690.250000       0.004741   \n",
       "2015-02-04 18:01:30     23.10000  27.100000  419.0  691.000000       0.004739   \n",
       "2015-02-04 18:02:00     23.10000  27.100000  419.0  691.000000       0.004739   \n",
       "2015-02-04 18:02:30     23.10000  27.166667  419.0  683.500000       0.004751   \n",
       "2015-02-04 18:03:00     23.10000  27.166667  419.0  683.500000       0.004751   \n",
       "2015-02-04 18:03:30     23.05000  27.150000  419.0  687.500000       0.004734   \n",
       "2015-02-04 18:04:00     23.05000  27.150000  419.0  687.500000       0.004734   \n",
       "2015-02-04 18:04:30     23.00000  27.125000  419.0  686.000000       0.004715   \n",
       "2015-02-04 18:05:00     23.00000  27.125000  419.0  686.000000       0.004715   \n",
       "2015-02-04 18:05:30     23.00000  27.125000  418.5  680.500000       0.004715   \n",
       "...                          ...        ...    ...         ...            ...   \n",
       "2015-02-10 09:18:30     20.91750  35.717500  433.0  706.250000       0.005474   \n",
       "2015-02-10 09:19:00     20.91750  35.717500  433.0  706.250000       0.005474   \n",
       "2015-02-10 09:19:30     20.95875  35.683750  433.0  712.625000       0.005483   \n",
       "2015-02-10 09:20:00     20.95875  35.683750  433.0  712.625000       0.005483   \n",
       "2015-02-10 09:20:30     21.00000  35.650000  433.0  719.000000       0.005492   \n",
       "2015-02-10 09:21:00     21.00000  35.650000  433.0  719.000000       0.005492   \n",
       "2015-02-10 09:21:30     21.00000  35.700000  433.0  730.250000       0.005500   \n",
       "2015-02-10 09:22:00     21.00000  35.700000  433.0  730.250000       0.005500   \n",
       "2015-02-10 09:22:30     21.00000  35.760000  433.0  739.000000       0.005509   \n",
       "2015-02-10 09:23:00     21.00000  35.760000  433.0  739.000000       0.005509   \n",
       "2015-02-10 09:23:30     21.00000  35.850000  433.0  756.250000       0.005523   \n",
       "2015-02-10 09:24:00     21.00000  35.850000  433.0  756.250000       0.005523   \n",
       "2015-02-10 09:24:30     21.00000  35.700000  433.0  761.000000       0.005500   \n",
       "2015-02-10 09:25:00     21.00000  35.700000  433.0  761.000000       0.005500   \n",
       "2015-02-10 09:25:30     21.02500  35.950000  433.0  763.000000       0.005547   \n",
       "2015-02-10 09:26:00     21.02500  35.950000  433.0  763.000000       0.005547   \n",
       "2015-02-10 09:26:30     21.00000  35.860000  433.0  771.333333       0.005525   \n",
       "2015-02-10 09:27:00     21.00000  35.860000  433.0  771.333333       0.005525   \n",
       "2015-02-10 09:27:30     21.05000  36.050000  433.0  780.250000       0.005571   \n",
       "2015-02-10 09:28:00     21.05000  36.050000  433.0  780.250000       0.005571   \n",
       "2015-02-10 09:28:30     21.05000  36.097500  433.0  787.250000       0.005579   \n",
       "2015-02-10 09:29:00     21.05000  36.097500  433.0  787.250000       0.005579   \n",
       "2015-02-10 09:29:30     21.05000  35.995000  433.0  789.500000       0.005563   \n",
       "2015-02-10 09:30:00     21.05000  35.995000  433.0  789.500000       0.005563   \n",
       "2015-02-10 09:30:30     21.10000  36.095000  433.0  798.500000       0.005596   \n",
       "2015-02-10 09:31:00     21.10000  36.095000  433.0  798.500000       0.005596   \n",
       "2015-02-10 09:31:30     21.10000  36.260000  433.0  820.333333       0.005621   \n",
       "2015-02-10 09:32:00     21.10000  36.260000  433.0  820.333333       0.005621   \n",
       "2015-02-10 09:32:30     21.10000  36.200000  447.0  821.000000       0.005612   \n",
       "2015-02-10 09:33:00     21.10000  36.200000  447.0  821.000000       0.005612   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00          1  \n",
       "2015-02-04 17:51:30          1  \n",
       "2015-02-04 17:52:00          1  \n",
       "2015-02-04 17:52:30          1  \n",
       "2015-02-04 17:53:00          1  \n",
       "2015-02-04 17:53:30          1  \n",
       "2015-02-04 17:54:00          1  \n",
       "2015-02-04 17:54:30          1  \n",
       "2015-02-04 17:55:00          1  \n",
       "2015-02-04 17:55:30          1  \n",
       "2015-02-04 17:56:00          1  \n",
       "2015-02-04 17:56:30          1  \n",
       "2015-02-04 17:57:00          1  \n",
       "2015-02-04 17:57:30          1  \n",
       "2015-02-04 17:58:00          1  \n",
       "2015-02-04 17:58:30          1  \n",
       "2015-02-04 17:59:00          1  \n",
       "2015-02-04 17:59:30          1  \n",
       "2015-02-04 18:00:00          1  \n",
       "2015-02-04 18:00:30          1  \n",
       "2015-02-04 18:01:00          1  \n",
       "2015-02-04 18:01:30          1  \n",
       "2015-02-04 18:02:00          1  \n",
       "2015-02-04 18:02:30          1  \n",
       "2015-02-04 18:03:00          1  \n",
       "2015-02-04 18:03:30          1  \n",
       "2015-02-04 18:04:00          1  \n",
       "2015-02-04 18:04:30          1  \n",
       "2015-02-04 18:05:00          1  \n",
       "2015-02-04 18:05:30          1  \n",
       "...                        ...  \n",
       "2015-02-10 09:18:30          1  \n",
       "2015-02-10 09:19:00          1  \n",
       "2015-02-10 09:19:30          1  \n",
       "2015-02-10 09:20:00          1  \n",
       "2015-02-10 09:20:30          1  \n",
       "2015-02-10 09:21:00          1  \n",
       "2015-02-10 09:21:30          1  \n",
       "2015-02-10 09:22:00          1  \n",
       "2015-02-10 09:22:30          1  \n",
       "2015-02-10 09:23:00          1  \n",
       "2015-02-10 09:23:30          1  \n",
       "2015-02-10 09:24:00          1  \n",
       "2015-02-10 09:24:30          1  \n",
       "2015-02-10 09:25:00          1  \n",
       "2015-02-10 09:25:30          1  \n",
       "2015-02-10 09:26:00          1  \n",
       "2015-02-10 09:26:30          1  \n",
       "2015-02-10 09:27:00          1  \n",
       "2015-02-10 09:27:30          1  \n",
       "2015-02-10 09:28:00          1  \n",
       "2015-02-10 09:28:30          1  \n",
       "2015-02-10 09:29:00          1  \n",
       "2015-02-10 09:29:30          1  \n",
       "2015-02-10 09:30:00          1  \n",
       "2015-02-10 09:30:30          1  \n",
       "2015-02-10 09:31:00          1  \n",
       "2015-02-10 09:31:30          1  \n",
       "2015-02-10 09:32:00          1  \n",
       "2015-02-10 09:32:30          1  \n",
       "2015-02-10 09:33:00          1  \n",
       "\n",
       "[16285 rows x 6 columns]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('30S').nearest()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Fill NaN values in the resampled data with nearest neighbor starting from center"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:01</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:02</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:03</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:04</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "date                                                                       \n",
       "2015-02-04 17:51:00        23.18    27.272  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:01        23.18    27.272  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:02        23.18    27.272  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:03        23.18    27.272  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:04        23.18    27.272  426.0  721.25       0.004793   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00          1  \n",
       "2015-02-04 17:51:01          1  \n",
       "2015-02-04 17:51:02          1  \n",
       "2015-02-04 17:51:03          1  \n",
       "2015-02-04 17:51:04          1  "
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('S').nearest().head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Fill NaN values using interpolation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.180000</td>\n",
       "      <td>27.272000</td>\n",
       "      <td>426.000000</td>\n",
       "      <td>721.250000</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:01</th>\n",
       "      <td>23.179492</td>\n",
       "      <td>27.271924</td>\n",
       "      <td>426.059322</td>\n",
       "      <td>721.127119</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:02</th>\n",
       "      <td>23.178983</td>\n",
       "      <td>27.271847</td>\n",
       "      <td>426.118644</td>\n",
       "      <td>721.004237</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:03</th>\n",
       "      <td>23.178475</td>\n",
       "      <td>27.271771</td>\n",
       "      <td>426.177966</td>\n",
       "      <td>720.881356</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:04</th>\n",
       "      <td>23.177966</td>\n",
       "      <td>27.271695</td>\n",
       "      <td>426.237288</td>\n",
       "      <td>720.758475</td>\n",
       "      <td>0.004792</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature   Humidity       Light         CO2  \\\n",
       "date                                                                  \n",
       "2015-02-04 17:51:00    23.180000  27.272000  426.000000  721.250000   \n",
       "2015-02-04 17:51:01    23.179492  27.271924  426.059322  721.127119   \n",
       "2015-02-04 17:51:02    23.178983  27.271847  426.118644  721.004237   \n",
       "2015-02-04 17:51:03    23.178475  27.271771  426.177966  720.881356   \n",
       "2015-02-04 17:51:04    23.177966  27.271695  426.237288  720.758475   \n",
       "\n",
       "                     HumidityRatio  Occupancy  \n",
       "date                                           \n",
       "2015-02-04 17:51:00       0.004793        1.0  \n",
       "2015-02-04 17:51:01       0.004793        1.0  \n",
       "2015-02-04 17:51:02       0.004793        1.0  \n",
       "2015-02-04 17:51:03       0.004793        1.0  \n",
       "2015-02-04 17:51:04       0.004792        1.0  "
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('S').interpolate().head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 2. понижение уровня дискретизации"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2015-02-04 17:51:00</td>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2015-02-04 17:51:59</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2675</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.00</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2015-02-04 17:53:00</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2450</td>\n",
       "      <td>426.0</td>\n",
       "      <td>713.50</td>\n",
       "      <td>0.004779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2015-02-04 17:54:00</td>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>708.25</td>\n",
       "      <td>0.004772</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2015-02-04 17:55:00</td>\n",
       "      <td>23.10</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>704.50</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  date  Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "1  2015-02-04 17:51:00        23.18   27.2720  426.0  721.25       0.004793   \n",
       "2  2015-02-04 17:51:59        23.15   27.2675  429.5  714.00       0.004783   \n",
       "3  2015-02-04 17:53:00        23.15   27.2450  426.0  713.50       0.004779   \n",
       "4  2015-02-04 17:54:00        23.15   27.2000  426.0  708.25       0.004772   \n",
       "5  2015-02-04 17:55:00        23.10   27.2000  426.0  704.50       0.004757   \n",
       "\n",
       "   Occupancy  \n",
       "1          1  \n",
       "2          1  \n",
       "3          1  \n",
       "4          1  \n",
       "5          1  "
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:50:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:00:00</th>\n",
       "      <td>23.075000</td>\n",
       "      <td>27.175</td>\n",
       "      <td>419.0</td>\n",
       "      <td>688.000000</td>\n",
       "      <td>0.004745</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:10:00</th>\n",
       "      <td>22.890000</td>\n",
       "      <td>27.390</td>\n",
       "      <td>0.0</td>\n",
       "      <td>689.000000</td>\n",
       "      <td>0.004730</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:20:00</th>\n",
       "      <td>22.745000</td>\n",
       "      <td>27.500</td>\n",
       "      <td>0.0</td>\n",
       "      <td>670.000000</td>\n",
       "      <td>0.004707</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:30:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:40:00</th>\n",
       "      <td>22.390000</td>\n",
       "      <td>27.340</td>\n",
       "      <td>0.0</td>\n",
       "      <td>630.500000</td>\n",
       "      <td>0.004579</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:50:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:00:00</th>\n",
       "      <td>22.290000</td>\n",
       "      <td>27.390</td>\n",
       "      <td>0.0</td>\n",
       "      <td>612.000000</td>\n",
       "      <td>0.004559</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:10:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:20:00</th>\n",
       "      <td>22.133333</td>\n",
       "      <td>27.200</td>\n",
       "      <td>0.0</td>\n",
       "      <td>584.666667</td>\n",
       "      <td>0.004484</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity  Light         CO2  HumidityRatio  \\\n",
       "date                                                                           \n",
       "2015-02-04 17:50:00          NaN       NaN    NaN         NaN            NaN   \n",
       "2015-02-04 18:00:00    23.075000    27.175  419.0  688.000000       0.004745   \n",
       "2015-02-04 18:10:00    22.890000    27.390    0.0  689.000000       0.004730   \n",
       "2015-02-04 18:20:00    22.745000    27.500    0.0  670.000000       0.004707   \n",
       "2015-02-04 18:30:00          NaN       NaN    NaN         NaN            NaN   \n",
       "2015-02-04 18:40:00    22.390000    27.340    0.0  630.500000       0.004579   \n",
       "2015-02-04 18:50:00          NaN       NaN    NaN         NaN            NaN   \n",
       "2015-02-04 19:00:00    22.290000    27.390    0.0  612.000000       0.004559   \n",
       "2015-02-04 19:10:00          NaN       NaN    NaN         NaN            NaN   \n",
       "2015-02-04 19:20:00    22.133333    27.200    0.0  584.666667       0.004484   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:50:00        NaN  \n",
       "2015-02-04 18:00:00        1.0  \n",
       "2015-02-04 18:10:00        0.0  \n",
       "2015-02-04 18:20:00        0.0  \n",
       "2015-02-04 18:30:00        NaN  \n",
       "2015-02-04 18:40:00        0.0  \n",
       "2015-02-04 18:50:00        NaN  \n",
       "2015-02-04 19:00:00        0.0  \n",
       "2015-02-04 19:10:00        NaN  \n",
       "2015-02-04 19:20:00        0.0  "
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('10min').asfreq().head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:50:00</th>\n",
       "      <td>23.125556</td>\n",
       "      <td>27.220500</td>\n",
       "      <td>423.277778</td>\n",
       "      <td>705.833333</td>\n",
       "      <td>0.004768</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:00:00</th>\n",
       "      <td>23.029000</td>\n",
       "      <td>27.187167</td>\n",
       "      <td>293.250000</td>\n",
       "      <td>685.825000</td>\n",
       "      <td>0.004734</td>\n",
       "      <td>0.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:10:00</th>\n",
       "      <td>22.850000</td>\n",
       "      <td>27.456000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>688.566667</td>\n",
       "      <td>0.004729</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:20:00</th>\n",
       "      <td>22.655606</td>\n",
       "      <td>27.457727</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>666.272727</td>\n",
       "      <td>0.004674</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:30:00</th>\n",
       "      <td>22.521111</td>\n",
       "      <td>27.420370</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>646.490741</td>\n",
       "      <td>0.004629</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:40:00</th>\n",
       "      <td>22.376364</td>\n",
       "      <td>27.429091</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>627.136364</td>\n",
       "      <td>0.004590</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:50:00</th>\n",
       "      <td>22.306667</td>\n",
       "      <td>27.369630</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>617.092593</td>\n",
       "      <td>0.004560</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:00:00</th>\n",
       "      <td>22.238864</td>\n",
       "      <td>27.289091</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>601.363636</td>\n",
       "      <td>0.004528</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:10:00</th>\n",
       "      <td>22.166667</td>\n",
       "      <td>27.250000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>588.092593</td>\n",
       "      <td>0.004501</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:20:00</th>\n",
       "      <td>22.125833</td>\n",
       "      <td>27.195000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>577.766667</td>\n",
       "      <td>0.004481</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature   Humidity       Light         CO2  \\\n",
       "date                                                                  \n",
       "2015-02-04 17:50:00    23.125556  27.220500  423.277778  705.833333   \n",
       "2015-02-04 18:00:00    23.029000  27.187167  293.250000  685.825000   \n",
       "2015-02-04 18:10:00    22.850000  27.456000    0.000000  688.566667   \n",
       "2015-02-04 18:20:00    22.655606  27.457727    0.000000  666.272727   \n",
       "2015-02-04 18:30:00    22.521111  27.420370    0.000000  646.490741   \n",
       "2015-02-04 18:40:00    22.376364  27.429091    0.000000  627.136364   \n",
       "2015-02-04 18:50:00    22.306667  27.369630    0.000000  617.092593   \n",
       "2015-02-04 19:00:00    22.238864  27.289091    0.000000  601.363636   \n",
       "2015-02-04 19:10:00    22.166667  27.250000    0.000000  588.092593   \n",
       "2015-02-04 19:20:00    22.125833  27.195000    0.000000  577.766667   \n",
       "\n",
       "                     HumidityRatio  Occupancy  \n",
       "date                                           \n",
       "2015-02-04 17:50:00       0.004768        1.0  \n",
       "2015-02-04 18:00:00       0.004734        0.7  \n",
       "2015-02-04 18:10:00       0.004729        0.0  \n",
       "2015-02-04 18:20:00       0.004674        0.0  \n",
       "2015-02-04 18:30:00       0.004629        0.0  \n",
       "2015-02-04 18:40:00       0.004590        0.0  \n",
       "2015-02-04 18:50:00       0.004560        0.0  \n",
       "2015-02-04 19:00:00       0.004528        0.0  \n",
       "2015-02-04 19:10:00       0.004501        0.0  \n",
       "2015-02-04 19:20:00       0.004481        0.0  "
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('10min').mean().head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:50:00</th>\n",
       "      <td>208.130000</td>\n",
       "      <td>244.984500</td>\n",
       "      <td>3809.5</td>\n",
       "      <td>6352.500000</td>\n",
       "      <td>0.042912</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:00:00</th>\n",
       "      <td>230.290000</td>\n",
       "      <td>271.871667</td>\n",
       "      <td>2932.5</td>\n",
       "      <td>6858.250000</td>\n",
       "      <td>0.047342</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:10:00</th>\n",
       "      <td>228.500000</td>\n",
       "      <td>274.560000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6885.666667</td>\n",
       "      <td>0.047294</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:20:00</th>\n",
       "      <td>249.211667</td>\n",
       "      <td>302.035000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7329.000000</td>\n",
       "      <td>0.051413</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:30:00</th>\n",
       "      <td>202.690000</td>\n",
       "      <td>246.783333</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5818.416667</td>\n",
       "      <td>0.041663</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:40:00</th>\n",
       "      <td>246.140000</td>\n",
       "      <td>301.720000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6898.500000</td>\n",
       "      <td>0.050488</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:50:00</th>\n",
       "      <td>200.760000</td>\n",
       "      <td>246.326667</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5553.833333</td>\n",
       "      <td>0.041043</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:00:00</th>\n",
       "      <td>244.627500</td>\n",
       "      <td>300.180000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6615.000000</td>\n",
       "      <td>0.049807</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:10:00</th>\n",
       "      <td>199.500000</td>\n",
       "      <td>245.250000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5292.833333</td>\n",
       "      <td>0.040513</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:20:00</th>\n",
       "      <td>221.258333</td>\n",
       "      <td>271.950000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5777.666667</td>\n",
       "      <td>0.044810</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature    Humidity   Light          CO2  \\\n",
       "date                                                                \n",
       "2015-02-04 17:50:00   208.130000  244.984500  3809.5  6352.500000   \n",
       "2015-02-04 18:00:00   230.290000  271.871667  2932.5  6858.250000   \n",
       "2015-02-04 18:10:00   228.500000  274.560000     0.0  6885.666667   \n",
       "2015-02-04 18:20:00   249.211667  302.035000     0.0  7329.000000   \n",
       "2015-02-04 18:30:00   202.690000  246.783333     0.0  5818.416667   \n",
       "2015-02-04 18:40:00   246.140000  301.720000     0.0  6898.500000   \n",
       "2015-02-04 18:50:00   200.760000  246.326667     0.0  5553.833333   \n",
       "2015-02-04 19:00:00   244.627500  300.180000     0.0  6615.000000   \n",
       "2015-02-04 19:10:00   199.500000  245.250000     0.0  5292.833333   \n",
       "2015-02-04 19:20:00   221.258333  271.950000     0.0  5777.666667   \n",
       "\n",
       "                     HumidityRatio  Occupancy  \n",
       "date                                           \n",
       "2015-02-04 17:50:00       0.042912          9  \n",
       "2015-02-04 18:00:00       0.047342          7  \n",
       "2015-02-04 18:10:00       0.047294          0  \n",
       "2015-02-04 18:20:00       0.051413          0  \n",
       "2015-02-04 18:30:00       0.041663          0  \n",
       "2015-02-04 18:40:00       0.050488          0  \n",
       "2015-02-04 18:50:00       0.041043          0  \n",
       "2015-02-04 19:00:00       0.049807          0  \n",
       "2015-02-04 19:10:00       0.040513          0  \n",
       "2015-02-04 19:20:00       0.044810          0  "
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('10min').sum().head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:50:00</th>\n",
       "      <td>23.180000</td>\n",
       "      <td>27.272000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.250000</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:00:00</th>\n",
       "      <td>23.075000</td>\n",
       "      <td>27.175000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>688.000000</td>\n",
       "      <td>0.004745</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:10:00</th>\n",
       "      <td>22.890000</td>\n",
       "      <td>27.390000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>689.000000</td>\n",
       "      <td>0.004730</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:20:00</th>\n",
       "      <td>22.745000</td>\n",
       "      <td>27.500000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>670.000000</td>\n",
       "      <td>0.004707</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:30:00</th>\n",
       "      <td>22.600000</td>\n",
       "      <td>27.426667</td>\n",
       "      <td>0.0</td>\n",
       "      <td>658.000000</td>\n",
       "      <td>0.004653</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:40:00</th>\n",
       "      <td>22.390000</td>\n",
       "      <td>27.340000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>630.500000</td>\n",
       "      <td>0.004579</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:50:00</th>\n",
       "      <td>22.290000</td>\n",
       "      <td>27.390000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>621.000000</td>\n",
       "      <td>0.004559</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:00:00</th>\n",
       "      <td>22.290000</td>\n",
       "      <td>27.390000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>612.000000</td>\n",
       "      <td>0.004559</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:10:00</th>\n",
       "      <td>22.200000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>595.000000</td>\n",
       "      <td>0.004502</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:20:00</th>\n",
       "      <td>22.133333</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>584.666667</td>\n",
       "      <td>0.004484</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature   Humidity  Light         CO2  HumidityRatio  \\\n",
       "date                                                                            \n",
       "2015-02-04 17:50:00    23.180000  27.272000  426.0  721.250000       0.004793   \n",
       "2015-02-04 18:00:00    23.075000  27.175000  419.0  688.000000       0.004745   \n",
       "2015-02-04 18:10:00    22.890000  27.390000    0.0  689.000000       0.004730   \n",
       "2015-02-04 18:20:00    22.745000  27.500000    0.0  670.000000       0.004707   \n",
       "2015-02-04 18:30:00    22.600000  27.426667    0.0  658.000000       0.004653   \n",
       "2015-02-04 18:40:00    22.390000  27.340000    0.0  630.500000       0.004579   \n",
       "2015-02-04 18:50:00    22.290000  27.390000    0.0  621.000000       0.004559   \n",
       "2015-02-04 19:00:00    22.290000  27.390000    0.0  612.000000       0.004559   \n",
       "2015-02-04 19:10:00    22.200000  27.200000    0.0  595.000000       0.004502   \n",
       "2015-02-04 19:20:00    22.133333  27.200000    0.0  584.666667       0.004484   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:50:00          1  \n",
       "2015-02-04 18:00:00          1  \n",
       "2015-02-04 18:10:00          0  \n",
       "2015-02-04 18:20:00          0  \n",
       "2015-02-04 18:30:00          0  \n",
       "2015-02-04 18:40:00          0  \n",
       "2015-02-04 18:50:00          0  \n",
       "2015-02-04 19:00:00          0  \n",
       "2015-02-04 19:10:00          0  \n",
       "2015-02-04 19:20:00          0  "
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('10min').nearest().head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:50:00</th>\n",
       "      <td>23.180000</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.250000</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:00:00</th>\n",
       "      <td>23.075000</td>\n",
       "      <td>27.175</td>\n",
       "      <td>419.0</td>\n",
       "      <td>688.000000</td>\n",
       "      <td>0.004745</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:10:00</th>\n",
       "      <td>22.890000</td>\n",
       "      <td>27.390</td>\n",
       "      <td>0.0</td>\n",
       "      <td>689.000000</td>\n",
       "      <td>0.004730</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:20:00</th>\n",
       "      <td>22.745000</td>\n",
       "      <td>27.500</td>\n",
       "      <td>0.0</td>\n",
       "      <td>670.000000</td>\n",
       "      <td>0.004707</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:30:00</th>\n",
       "      <td>22.600000</td>\n",
       "      <td>27.445</td>\n",
       "      <td>0.0</td>\n",
       "      <td>655.000000</td>\n",
       "      <td>0.004656</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:40:00</th>\n",
       "      <td>22.390000</td>\n",
       "      <td>27.340</td>\n",
       "      <td>0.0</td>\n",
       "      <td>630.500000</td>\n",
       "      <td>0.004579</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:50:00</th>\n",
       "      <td>22.340000</td>\n",
       "      <td>27.390</td>\n",
       "      <td>0.0</td>\n",
       "      <td>626.500000</td>\n",
       "      <td>0.004573</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:00:00</th>\n",
       "      <td>22.290000</td>\n",
       "      <td>27.390</td>\n",
       "      <td>0.0</td>\n",
       "      <td>612.000000</td>\n",
       "      <td>0.004559</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:10:00</th>\n",
       "      <td>22.200000</td>\n",
       "      <td>27.290</td>\n",
       "      <td>0.0</td>\n",
       "      <td>594.333333</td>\n",
       "      <td>0.004517</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:20:00</th>\n",
       "      <td>22.133333</td>\n",
       "      <td>27.200</td>\n",
       "      <td>0.0</td>\n",
       "      <td>584.666667</td>\n",
       "      <td>0.004484</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity  Light         CO2  HumidityRatio  \\\n",
       "date                                                                           \n",
       "2015-02-04 17:50:00    23.180000    27.272  426.0  721.250000       0.004793   \n",
       "2015-02-04 18:00:00    23.075000    27.175  419.0  688.000000       0.004745   \n",
       "2015-02-04 18:10:00    22.890000    27.390    0.0  689.000000       0.004730   \n",
       "2015-02-04 18:20:00    22.745000    27.500    0.0  670.000000       0.004707   \n",
       "2015-02-04 18:30:00    22.600000    27.445    0.0  655.000000       0.004656   \n",
       "2015-02-04 18:40:00    22.390000    27.340    0.0  630.500000       0.004579   \n",
       "2015-02-04 18:50:00    22.340000    27.390    0.0  626.500000       0.004573   \n",
       "2015-02-04 19:00:00    22.290000    27.390    0.0  612.000000       0.004559   \n",
       "2015-02-04 19:10:00    22.200000    27.290    0.0  594.333333       0.004517   \n",
       "2015-02-04 19:20:00    22.133333    27.200    0.0  584.666667       0.004484   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:50:00          1  \n",
       "2015-02-04 18:00:00          1  \n",
       "2015-02-04 18:10:00          0  \n",
       "2015-02-04 18:20:00          0  \n",
       "2015-02-04 18:30:00          0  \n",
       "2015-02-04 18:40:00          0  \n",
       "2015-02-04 18:50:00          0  \n",
       "2015-02-04 19:00:00          0  \n",
       "2015-02-04 19:10:00          0  \n",
       "2015-02-04 19:20:00          0  "
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('10min').bfill().head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:50:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:00:00</th>\n",
       "      <td>23.075000</td>\n",
       "      <td>27.175000</td>\n",
       "      <td>419.0</td>\n",
       "      <td>688.000000</td>\n",
       "      <td>0.004745</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:10:00</th>\n",
       "      <td>22.890000</td>\n",
       "      <td>27.390000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>689.000000</td>\n",
       "      <td>0.004730</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:20:00</th>\n",
       "      <td>22.745000</td>\n",
       "      <td>27.500000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>670.000000</td>\n",
       "      <td>0.004707</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:30:00</th>\n",
       "      <td>22.600000</td>\n",
       "      <td>27.426667</td>\n",
       "      <td>0.0</td>\n",
       "      <td>658.000000</td>\n",
       "      <td>0.004653</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:40:00</th>\n",
       "      <td>22.390000</td>\n",
       "      <td>27.340000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>630.500000</td>\n",
       "      <td>0.004579</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:50:00</th>\n",
       "      <td>22.290000</td>\n",
       "      <td>27.390000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>621.000000</td>\n",
       "      <td>0.004559</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:00:00</th>\n",
       "      <td>22.290000</td>\n",
       "      <td>27.390000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>612.000000</td>\n",
       "      <td>0.004559</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:10:00</th>\n",
       "      <td>22.200000</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>595.000000</td>\n",
       "      <td>0.004502</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:20:00</th>\n",
       "      <td>22.133333</td>\n",
       "      <td>27.200000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>584.666667</td>\n",
       "      <td>0.004484</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature   Humidity  Light         CO2  HumidityRatio  \\\n",
       "date                                                                            \n",
       "2015-02-04 17:50:00          NaN        NaN    NaN         NaN            NaN   \n",
       "2015-02-04 18:00:00    23.075000  27.175000  419.0  688.000000       0.004745   \n",
       "2015-02-04 18:10:00    22.890000  27.390000    0.0  689.000000       0.004730   \n",
       "2015-02-04 18:20:00    22.745000  27.500000    0.0  670.000000       0.004707   \n",
       "2015-02-04 18:30:00    22.600000  27.426667    0.0  658.000000       0.004653   \n",
       "2015-02-04 18:40:00    22.390000  27.340000    0.0  630.500000       0.004579   \n",
       "2015-02-04 18:50:00    22.290000  27.390000    0.0  621.000000       0.004559   \n",
       "2015-02-04 19:00:00    22.290000  27.390000    0.0  612.000000       0.004559   \n",
       "2015-02-04 19:10:00    22.200000  27.200000    0.0  595.000000       0.004502   \n",
       "2015-02-04 19:20:00    22.133333  27.200000    0.0  584.666667       0.004484   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:50:00        NaN  \n",
       "2015-02-04 18:00:00        1.0  \n",
       "2015-02-04 18:10:00        0.0  \n",
       "2015-02-04 18:20:00        0.0  \n",
       "2015-02-04 18:30:00        0.0  \n",
       "2015-02-04 18:40:00        0.0  \n",
       "2015-02-04 18:50:00        0.0  \n",
       "2015-02-04 19:00:00        0.0  \n",
       "2015-02-04 19:10:00        0.0  \n",
       "2015-02-04 19:20:00        0.0  "
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('10min').pad().head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Другие частоты:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:00:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:00:00</th>\n",
       "      <td>23.075</td>\n",
       "      <td>27.175</td>\n",
       "      <td>419.0</td>\n",
       "      <td>688.0</td>\n",
       "      <td>0.004745</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 19:00:00</th>\n",
       "      <td>22.290</td>\n",
       "      <td>27.390</td>\n",
       "      <td>0.0</td>\n",
       "      <td>612.0</td>\n",
       "      <td>0.004559</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 20:00:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 21:00:00</th>\n",
       "      <td>21.600</td>\n",
       "      <td>26.290</td>\n",
       "      <td>0.0</td>\n",
       "      <td>503.5</td>\n",
       "      <td>0.004193</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 22:00:00</th>\n",
       "      <td>21.390</td>\n",
       "      <td>25.700</td>\n",
       "      <td>0.0</td>\n",
       "      <td>488.0</td>\n",
       "      <td>0.004046</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 23:00:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-05 00:00:00</th>\n",
       "      <td>21.245</td>\n",
       "      <td>25.245</td>\n",
       "      <td>0.0</td>\n",
       "      <td>456.5</td>\n",
       "      <td>0.003938</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-05 01:00:00</th>\n",
       "      <td>21.100</td>\n",
       "      <td>25.390</td>\n",
       "      <td>0.0</td>\n",
       "      <td>452.0</td>\n",
       "      <td>0.003926</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-05 02:00:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity  Light    CO2  HumidityRatio  \\\n",
       "date                                                                      \n",
       "2015-02-04 17:00:00          NaN       NaN    NaN    NaN            NaN   \n",
       "2015-02-04 18:00:00       23.075    27.175  419.0  688.0       0.004745   \n",
       "2015-02-04 19:00:00       22.290    27.390    0.0  612.0       0.004559   \n",
       "2015-02-04 20:00:00          NaN       NaN    NaN    NaN            NaN   \n",
       "2015-02-04 21:00:00       21.600    26.290    0.0  503.5       0.004193   \n",
       "2015-02-04 22:00:00       21.390    25.700    0.0  488.0       0.004046   \n",
       "2015-02-04 23:00:00          NaN       NaN    NaN    NaN            NaN   \n",
       "2015-02-05 00:00:00       21.245    25.245    0.0  456.5       0.003938   \n",
       "2015-02-05 01:00:00       21.100    25.390    0.0  452.0       0.003926   \n",
       "2015-02-05 02:00:00          NaN       NaN    NaN    NaN            NaN   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:00:00        NaN  \n",
       "2015-02-04 18:00:00        1.0  \n",
       "2015-02-04 19:00:00        0.0  \n",
       "2015-02-04 20:00:00        NaN  \n",
       "2015-02-04 21:00:00        0.0  \n",
       "2015-02-04 22:00:00        0.0  \n",
       "2015-02-04 23:00:00        NaN  \n",
       "2015-02-05 00:00:00        0.0  \n",
       "2015-02-05 01:00:00        0.0  \n",
       "2015-02-05 02:00:00        NaN  "
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('1H').asfreq().head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-05</th>\n",
       "      <td>21.245</td>\n",
       "      <td>25.245</td>\n",
       "      <td>0.0</td>\n",
       "      <td>456.5</td>\n",
       "      <td>0.003938</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-06</th>\n",
       "      <td>20.200</td>\n",
       "      <td>21.290</td>\n",
       "      <td>0.0</td>\n",
       "      <td>438.0</td>\n",
       "      <td>0.003110</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-07</th>\n",
       "      <td>20.000</td>\n",
       "      <td>18.700</td>\n",
       "      <td>0.0</td>\n",
       "      <td>438.0</td>\n",
       "      <td>0.002696</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-08</th>\n",
       "      <td>19.600</td>\n",
       "      <td>29.390</td>\n",
       "      <td>0.0</td>\n",
       "      <td>438.5</td>\n",
       "      <td>0.004143</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-09</th>\n",
       "      <td>19.500</td>\n",
       "      <td>27.100</td>\n",
       "      <td>0.0</td>\n",
       "      <td>459.0</td>\n",
       "      <td>0.003795</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10</th>\n",
       "      <td>20.390</td>\n",
       "      <td>32.950</td>\n",
       "      <td>0.0</td>\n",
       "      <td>498.5</td>\n",
       "      <td>0.004884</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Temperature  Humidity  Light    CO2  HumidityRatio  Occupancy\n",
       "date                                                                     \n",
       "2015-02-04          NaN       NaN    NaN    NaN            NaN        NaN\n",
       "2015-02-05       21.245    25.245    0.0  456.5       0.003938        0.0\n",
       "2015-02-06       20.200    21.290    0.0  438.0       0.003110        0.0\n",
       "2015-02-07       20.000    18.700    0.0  438.0       0.002696        0.0\n",
       "2015-02-08       19.600    29.390    0.0  438.5       0.004143        0.0\n",
       "2015-02-09       19.500    27.100    0.0  459.0       0.003795        0.0\n",
       "2015-02-10       20.390    32.950    0.0  498.5       0.004884        0.0"
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('D').asfreq().head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 12:00:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-05 00:00:00</th>\n",
       "      <td>21.245</td>\n",
       "      <td>25.2450</td>\n",
       "      <td>0.00</td>\n",
       "      <td>456.5</td>\n",
       "      <td>0.003938</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-05 12:00:00</th>\n",
       "      <td>22.200</td>\n",
       "      <td>27.1000</td>\n",
       "      <td>464.00</td>\n",
       "      <td>1118.0</td>\n",
       "      <td>0.004486</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-06 00:00:00</th>\n",
       "      <td>20.200</td>\n",
       "      <td>21.2900</td>\n",
       "      <td>0.00</td>\n",
       "      <td>438.0</td>\n",
       "      <td>0.003110</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-06 12:00:00</th>\n",
       "      <td>21.675</td>\n",
       "      <td>20.4175</td>\n",
       "      <td>501.50</td>\n",
       "      <td>802.0</td>\n",
       "      <td>0.003267</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-07 00:00:00</th>\n",
       "      <td>20.000</td>\n",
       "      <td>18.7000</td>\n",
       "      <td>0.00</td>\n",
       "      <td>438.0</td>\n",
       "      <td>0.002696</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-07 12:00:00</th>\n",
       "      <td>22.890</td>\n",
       "      <td>17.6000</td>\n",
       "      <td>352.25</td>\n",
       "      <td>453.0</td>\n",
       "      <td>0.003031</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-08 00:00:00</th>\n",
       "      <td>19.600</td>\n",
       "      <td>29.3900</td>\n",
       "      <td>0.00</td>\n",
       "      <td>438.5</td>\n",
       "      <td>0.004143</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-08 12:00:00</th>\n",
       "      <td>19.200</td>\n",
       "      <td>30.7900</td>\n",
       "      <td>53.00</td>\n",
       "      <td>421.5</td>\n",
       "      <td>0.004235</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-09 00:00:00</th>\n",
       "      <td>19.500</td>\n",
       "      <td>27.1000</td>\n",
       "      <td>0.00</td>\n",
       "      <td>459.0</td>\n",
       "      <td>0.003795</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity   Light     CO2  HumidityRatio  \\\n",
       "date                                                                        \n",
       "2015-02-04 12:00:00          NaN       NaN     NaN     NaN            NaN   \n",
       "2015-02-05 00:00:00       21.245   25.2450    0.00   456.5       0.003938   \n",
       "2015-02-05 12:00:00       22.200   27.1000  464.00  1118.0       0.004486   \n",
       "2015-02-06 00:00:00       20.200   21.2900    0.00   438.0       0.003110   \n",
       "2015-02-06 12:00:00       21.675   20.4175  501.50   802.0       0.003267   \n",
       "2015-02-07 00:00:00       20.000   18.7000    0.00   438.0       0.002696   \n",
       "2015-02-07 12:00:00       22.890   17.6000  352.25   453.0       0.003031   \n",
       "2015-02-08 00:00:00       19.600   29.3900    0.00   438.5       0.004143   \n",
       "2015-02-08 12:00:00       19.200   30.7900   53.00   421.5       0.004235   \n",
       "2015-02-09 00:00:00       19.500   27.1000    0.00   459.0       0.003795   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 12:00:00        NaN  \n",
       "2015-02-05 00:00:00        0.0  \n",
       "2015-02-05 12:00:00        1.0  \n",
       "2015-02-06 00:00:00        0.0  \n",
       "2015-02-06 12:00:00        1.0  \n",
       "2015-02-07 00:00:00        0.0  \n",
       "2015-02-07 12:00:00        0.0  \n",
       "2015-02-08 00:00:00        0.0  \n",
       "2015-02-08 12:00:00        0.0  \n",
       "2015-02-09 00:00:00        0.0  "
      ]
     },
     "execution_count": 115,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.resample('12H').asfreq().head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. Оконные функции: Rolling \n",
    "\n",
    "Иногда по данным нужно пройти каким-то окном и посчитать что-то внутри этих окон. Например, то самое скользящее среднее и т.д. Как это можно сделать?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2675</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.00</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2450</td>\n",
       "      <td>426.0</td>\n",
       "      <td>713.50</td>\n",
       "      <td>0.004779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>708.25</td>\n",
       "      <td>0.004772</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>23.10</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>704.50</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "date                                                                       \n",
       "2015-02-04 17:51:00        23.18   27.2720  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:59        23.15   27.2675  429.5  714.00       0.004783   \n",
       "2015-02-04 17:53:00        23.15   27.2450  426.0  713.50       0.004779   \n",
       "2015-02-04 17:54:00        23.15   27.2000  426.0  708.25       0.004772   \n",
       "2015-02-04 17:55:00        23.10   27.2000  426.0  704.50       0.004757   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00          1  \n",
       "2015-02-04 17:51:59          1  \n",
       "2015-02-04 17:53:00          1  \n",
       "2015-02-04 17:54:00          1  \n",
       "2015-02-04 17:55:00          1  "
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>69.48</td>\n",
       "      <td>81.7845</td>\n",
       "      <td>1281.5</td>\n",
       "      <td>2148.75</td>\n",
       "      <td>0.014356</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>69.45</td>\n",
       "      <td>81.7125</td>\n",
       "      <td>1281.5</td>\n",
       "      <td>2135.75</td>\n",
       "      <td>0.014334</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>69.40</td>\n",
       "      <td>81.6450</td>\n",
       "      <td>1278.0</td>\n",
       "      <td>2126.25</td>\n",
       "      <td>0.014308</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity   Light      CO2  HumidityRatio  \\\n",
       "date                                                                         \n",
       "2015-02-04 17:51:00          NaN       NaN     NaN      NaN            NaN   \n",
       "2015-02-04 17:51:59          NaN       NaN     NaN      NaN            NaN   \n",
       "2015-02-04 17:53:00        69.48   81.7845  1281.5  2148.75       0.014356   \n",
       "2015-02-04 17:54:00        69.45   81.7125  1281.5  2135.75       0.014334   \n",
       "2015-02-04 17:55:00        69.40   81.6450  1278.0  2126.25       0.014308   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00        NaN  \n",
       "2015-02-04 17:51:59        NaN  \n",
       "2015-02-04 17:53:00        3.0  \n",
       "2015-02-04 17:54:00        3.0  \n",
       "2015-02-04 17:55:00        3.0  "
      ]
     },
     "execution_count": 122,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# сумма по движущемуся окну = 3\n",
    "data.rolling(3).sum().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.180000</td>\n",
       "      <td>27.27200</td>\n",
       "      <td>426.000000</td>\n",
       "      <td>721.250000</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>23.165000</td>\n",
       "      <td>27.26975</td>\n",
       "      <td>427.750000</td>\n",
       "      <td>717.625000</td>\n",
       "      <td>0.004788</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>23.160000</td>\n",
       "      <td>27.26150</td>\n",
       "      <td>427.166667</td>\n",
       "      <td>716.250000</td>\n",
       "      <td>0.004785</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>23.150000</td>\n",
       "      <td>27.23750</td>\n",
       "      <td>427.166667</td>\n",
       "      <td>711.916667</td>\n",
       "      <td>0.004778</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>23.133333</td>\n",
       "      <td>27.21500</td>\n",
       "      <td>426.000000</td>\n",
       "      <td>708.750000</td>\n",
       "      <td>0.004769</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity       Light         CO2  \\\n",
       "date                                                                 \n",
       "2015-02-04 17:51:00    23.180000  27.27200  426.000000  721.250000   \n",
       "2015-02-04 17:51:59    23.165000  27.26975  427.750000  717.625000   \n",
       "2015-02-04 17:53:00    23.160000  27.26150  427.166667  716.250000   \n",
       "2015-02-04 17:54:00    23.150000  27.23750  427.166667  711.916667   \n",
       "2015-02-04 17:55:00    23.133333  27.21500  426.000000  708.750000   \n",
       "\n",
       "                     HumidityRatio  Occupancy  \n",
       "date                                           \n",
       "2015-02-04 17:51:00       0.004793        1.0  \n",
       "2015-02-04 17:51:59       0.004788        1.0  \n",
       "2015-02-04 17:53:00       0.004785        1.0  \n",
       "2015-02-04 17:54:00       0.004778        1.0  \n",
       "2015-02-04 17:55:00       0.004769        1.0  "
      ]
     },
     "execution_count": 127,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# среднее по движущемуся окну = 3\n",
    "data.rolling(3, min_periods=1).mean().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.180000</td>\n",
       "      <td>27.27200</td>\n",
       "      <td>426.000000</td>\n",
       "      <td>721.250000</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>23.165000</td>\n",
       "      <td>27.26975</td>\n",
       "      <td>427.750000</td>\n",
       "      <td>717.625000</td>\n",
       "      <td>0.004788</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>23.160000</td>\n",
       "      <td>27.26150</td>\n",
       "      <td>427.166667</td>\n",
       "      <td>716.250000</td>\n",
       "      <td>0.004785</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>23.150000</td>\n",
       "      <td>27.23750</td>\n",
       "      <td>427.166667</td>\n",
       "      <td>711.916667</td>\n",
       "      <td>0.004778</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>23.133333</td>\n",
       "      <td>27.21500</td>\n",
       "      <td>426.000000</td>\n",
       "      <td>708.750000</td>\n",
       "      <td>0.004769</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity       Light         CO2  \\\n",
       "date                                                                 \n",
       "2015-02-04 17:51:00    23.180000  27.27200  426.000000  721.250000   \n",
       "2015-02-04 17:51:59    23.165000  27.26975  427.750000  717.625000   \n",
       "2015-02-04 17:53:00    23.160000  27.26150  427.166667  716.250000   \n",
       "2015-02-04 17:54:00    23.150000  27.23750  427.166667  711.916667   \n",
       "2015-02-04 17:55:00    23.133333  27.21500  426.000000  708.750000   \n",
       "\n",
       "                     HumidityRatio  Occupancy  \n",
       "date                                           \n",
       "2015-02-04 17:51:00       0.004793        1.0  \n",
       "2015-02-04 17:51:59       0.004788        1.0  \n",
       "2015-02-04 17:53:00       0.004785        1.0  \n",
       "2015-02-04 17:54:00       0.004778        1.0  \n",
       "2015-02-04 17:55:00       0.004769        1.0  "
      ]
     },
     "execution_count": 129,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# среднее по окну в 3 минуты\n",
    "data.rolling('3min', min_periods=1).mean().head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. Встроенные статистические функции\n",
    "\n",
    "Кроме уже известных и понятных нам суммы и среднего, есть и другие. Давайте на них посмотрим:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1. Корреляция"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Обычный коэффициент корреляции Пирсона"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Temperature</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>-0.141759</td>\n",
       "      <td>0.649942</td>\n",
       "      <td>0.559894</td>\n",
       "      <td>0.151762</td>\n",
       "      <td>0.538220</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Humidity</th>\n",
       "      <td>-0.141759</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.037828</td>\n",
       "      <td>0.439023</td>\n",
       "      <td>0.955198</td>\n",
       "      <td>0.132964</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Light</th>\n",
       "      <td>0.649942</td>\n",
       "      <td>0.037828</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.664022</td>\n",
       "      <td>0.230420</td>\n",
       "      <td>0.907352</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CO2</th>\n",
       "      <td>0.559894</td>\n",
       "      <td>0.439023</td>\n",
       "      <td>0.664022</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.626556</td>\n",
       "      <td>0.712235</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HumidityRatio</th>\n",
       "      <td>0.151762</td>\n",
       "      <td>0.955198</td>\n",
       "      <td>0.230420</td>\n",
       "      <td>0.626556</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.300282</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Occupancy</th>\n",
       "      <td>0.538220</td>\n",
       "      <td>0.132964</td>\n",
       "      <td>0.907352</td>\n",
       "      <td>0.712235</td>\n",
       "      <td>0.300282</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               Temperature  Humidity     Light       CO2  HumidityRatio  \\\n",
       "Temperature       1.000000 -0.141759  0.649942  0.559894       0.151762   \n",
       "Humidity         -0.141759  1.000000  0.037828  0.439023       0.955198   \n",
       "Light             0.649942  0.037828  1.000000  0.664022       0.230420   \n",
       "CO2               0.559894  0.439023  0.664022  1.000000       0.626556   \n",
       "HumidityRatio     0.151762  0.955198  0.230420  0.626556       1.000000   \n",
       "Occupancy         0.538220  0.132964  0.907352  0.712235       0.300282   \n",
       "\n",
       "               Occupancy  \n",
       "Temperature     0.538220  \n",
       "Humidity        0.132964  \n",
       "Light           0.907352  \n",
       "CO2             0.712235  \n",
       "HumidityRatio   0.300282  \n",
       "Occupancy       1.000000  "
      ]
     },
     "execution_count": 130,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.corr()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Коэффициент корреляции Kendall Tau"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Temperature</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>-0.110486</td>\n",
       "      <td>0.415524</td>\n",
       "      <td>0.454057</td>\n",
       "      <td>0.085116</td>\n",
       "      <td>0.439836</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Humidity</th>\n",
       "      <td>-0.110486</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000452</td>\n",
       "      <td>0.169497</td>\n",
       "      <td>0.808515</td>\n",
       "      <td>0.105824</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Light</th>\n",
       "      <td>0.415524</td>\n",
       "      <td>0.000452</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.337398</td>\n",
       "      <td>0.130088</td>\n",
       "      <td>0.734405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CO2</th>\n",
       "      <td>0.454057</td>\n",
       "      <td>0.169497</td>\n",
       "      <td>0.337398</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.271553</td>\n",
       "      <td>0.537307</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HumidityRatio</th>\n",
       "      <td>0.085116</td>\n",
       "      <td>0.808515</td>\n",
       "      <td>0.130088</td>\n",
       "      <td>0.271553</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.209033</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Occupancy</th>\n",
       "      <td>0.439836</td>\n",
       "      <td>0.105824</td>\n",
       "      <td>0.734405</td>\n",
       "      <td>0.537307</td>\n",
       "      <td>0.209033</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               Temperature  Humidity     Light       CO2  HumidityRatio  \\\n",
       "Temperature       1.000000 -0.110486  0.415524  0.454057       0.085116   \n",
       "Humidity         -0.110486  1.000000  0.000452  0.169497       0.808515   \n",
       "Light             0.415524  0.000452  1.000000  0.337398       0.130088   \n",
       "CO2               0.454057  0.169497  0.337398  1.000000       0.271553   \n",
       "HumidityRatio     0.085116  0.808515  0.130088  0.271553       1.000000   \n",
       "Occupancy         0.439836  0.105824  0.734405  0.537307       0.209033   \n",
       "\n",
       "               Occupancy  \n",
       "Temperature     0.439836  \n",
       "Humidity        0.105824  \n",
       "Light           0.734405  \n",
       "CO2             0.537307  \n",
       "HumidityRatio   0.209033  \n",
       "Occupancy       1.000000  "
      ]
     },
     "execution_count": 133,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.corr('kendall')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Ранговая корреляция Спирмана"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Temperature</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>-0.193389</td>\n",
       "      <td>0.565237</td>\n",
       "      <td>0.636906</td>\n",
       "      <td>0.104765</td>\n",
       "      <td>0.532830</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Humidity</th>\n",
       "      <td>-0.193389</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.007065</td>\n",
       "      <td>0.223519</td>\n",
       "      <td>0.940327</td>\n",
       "      <td>0.129235</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Light</th>\n",
       "      <td>0.565237</td>\n",
       "      <td>0.007065</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.473103</td>\n",
       "      <td>0.169057</td>\n",
       "      <td>0.804645</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CO2</th>\n",
       "      <td>0.636906</td>\n",
       "      <td>0.223519</td>\n",
       "      <td>0.473103</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.378357</td>\n",
       "      <td>0.656651</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HumidityRatio</th>\n",
       "      <td>0.104765</td>\n",
       "      <td>0.940327</td>\n",
       "      <td>0.169057</td>\n",
       "      <td>0.378357</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.255836</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Occupancy</th>\n",
       "      <td>0.532830</td>\n",
       "      <td>0.129235</td>\n",
       "      <td>0.804645</td>\n",
       "      <td>0.656651</td>\n",
       "      <td>0.255836</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               Temperature  Humidity     Light       CO2  HumidityRatio  \\\n",
       "Temperature       1.000000 -0.193389  0.565237  0.636906       0.104765   \n",
       "Humidity         -0.193389  1.000000  0.007065  0.223519       0.940327   \n",
       "Light             0.565237  0.007065  1.000000  0.473103       0.169057   \n",
       "CO2               0.636906  0.223519  0.473103  1.000000       0.378357   \n",
       "HumidityRatio     0.104765  0.940327  0.169057  0.378357       1.000000   \n",
       "Occupancy         0.532830  0.129235  0.804645  0.656651       0.255836   \n",
       "\n",
       "               Occupancy  \n",
       "Temperature     0.532830  \n",
       "Humidity        0.129235  \n",
       "Light           0.804645  \n",
       "CO2             0.656651  \n",
       "HumidityRatio   0.255836  \n",
       "Occupancy       1.000000  "
      ]
     },
     "execution_count": 137,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.corr('spearman')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. Медиана"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Temperature       20.390000\n",
       "Humidity          26.222500\n",
       "Light              0.000000\n",
       "CO2              453.500000\n",
       "HumidityRatio      0.003801\n",
       "Occupancy          0.000000\n",
       "dtype: float64"
      ]
     },
     "execution_count": 140,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.median()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3. Квантили"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0.95</th>\n",
       "      <td>22.39</td>\n",
       "      <td>34.4220</td>\n",
       "      <td>480.666667</td>\n",
       "      <td>1293.675</td>\n",
       "      <td>0.005336</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0.05</th>\n",
       "      <td>19.29</td>\n",
       "      <td>18.6000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>428.000</td>\n",
       "      <td>0.002730</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0.50</th>\n",
       "      <td>20.39</td>\n",
       "      <td>26.2225</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>453.500</td>\n",
       "      <td>0.003801</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Temperature  Humidity       Light       CO2  HumidityRatio  Occupancy\n",
       "0.95        22.39   34.4220  480.666667  1293.675       0.005336        1.0\n",
       "0.05        19.29   18.6000    0.000000   428.000       0.002730        0.0\n",
       "0.50        20.39   26.2225    0.000000   453.500       0.003801        0.0"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.quantile([0.95, 0.05, 0.5])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4. Уникальные значения и их количество"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Temperature       265\n",
       "Humidity         1325\n",
       "Light             889\n",
       "CO2              2282\n",
       "HumidityRatio    3583\n",
       "Occupancy           2\n",
       "dtype: int64"
      ]
     },
     "execution_count": 149,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 0], dtype=int64)"
      ]
     },
     "execution_count": 151,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.Occupancy.unique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5. Кумулятивные функции"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2675</td>\n",
       "      <td>429.5</td>\n",
       "      <td>714.00</td>\n",
       "      <td>0.004783</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2450</td>\n",
       "      <td>426.0</td>\n",
       "      <td>713.50</td>\n",
       "      <td>0.004779</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>23.15</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>708.25</td>\n",
       "      <td>0.004772</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>23.10</td>\n",
       "      <td>27.2000</td>\n",
       "      <td>426.0</td>\n",
       "      <td>704.50</td>\n",
       "      <td>0.004757</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "date                                                                       \n",
       "2015-02-04 17:51:00        23.18   27.2720  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:59        23.15   27.2675  429.5  714.00       0.004783   \n",
       "2015-02-04 17:53:00        23.15   27.2450  426.0  713.50       0.004779   \n",
       "2015-02-04 17:54:00        23.15   27.2000  426.0  708.25       0.004772   \n",
       "2015-02-04 17:55:00        23.10   27.2000  426.0  704.50       0.004757   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00          1  \n",
       "2015-02-04 17:51:59          1  \n",
       "2015-02-04 17:53:00          1  \n",
       "2015-02-04 17:54:00          1  \n",
       "2015-02-04 17:55:00          1  "
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>426.0</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>429.5</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>429.5</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>429.5</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.272</td>\n",
       "      <td>429.5</td>\n",
       "      <td>721.25</td>\n",
       "      <td>0.004793</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity  Light     CO2  HumidityRatio  \\\n",
       "date                                                                       \n",
       "2015-02-04 17:51:00        23.18    27.272  426.0  721.25       0.004793   \n",
       "2015-02-04 17:51:59        23.18    27.272  429.5  721.25       0.004793   \n",
       "2015-02-04 17:53:00        23.18    27.272  429.5  721.25       0.004793   \n",
       "2015-02-04 17:54:00        23.18    27.272  429.5  721.25       0.004793   \n",
       "2015-02-04 17:55:00        23.18    27.272  429.5  721.25       0.004793   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00        1.0  \n",
       "2015-02-04 17:51:59        1.0  \n",
       "2015-02-04 17:53:00        1.0  \n",
       "2015-02-04 17:54:00        1.0  \n",
       "2015-02-04 17:55:00        1.0  "
      ]
     },
     "execution_count": 165,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.cummax().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>2.318000e+01</td>\n",
       "      <td>2.727200e+01</td>\n",
       "      <td>4.260000e+02</td>\n",
       "      <td>7.212500e+02</td>\n",
       "      <td>4.792988e-03</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>5.366170e+02</td>\n",
       "      <td>7.436393e+02</td>\n",
       "      <td>1.829670e+05</td>\n",
       "      <td>5.149725e+05</td>\n",
       "      <td>2.292698e-05</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>1.242268e+04</td>\n",
       "      <td>2.026045e+04</td>\n",
       "      <td>7.794394e+07</td>\n",
       "      <td>3.674329e+08</td>\n",
       "      <td>1.095786e-07</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>2.875851e+05</td>\n",
       "      <td>5.510843e+05</td>\n",
       "      <td>3.320412e+10</td>\n",
       "      <td>2.602343e+11</td>\n",
       "      <td>5.228555e-10</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>6.643216e+06</td>\n",
       "      <td>1.498949e+07</td>\n",
       "      <td>1.414495e+13</td>\n",
       "      <td>1.833351e+14</td>\n",
       "      <td>2.487220e-12</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      Temperature      Humidity         Light           CO2  \\\n",
       "date                                                                          \n",
       "2015-02-04 17:51:00  2.318000e+01  2.727200e+01  4.260000e+02  7.212500e+02   \n",
       "2015-02-04 17:51:59  5.366170e+02  7.436393e+02  1.829670e+05  5.149725e+05   \n",
       "2015-02-04 17:53:00  1.242268e+04  2.026045e+04  7.794394e+07  3.674329e+08   \n",
       "2015-02-04 17:54:00  2.875851e+05  5.510843e+05  3.320412e+10  2.602343e+11   \n",
       "2015-02-04 17:55:00  6.643216e+06  1.498949e+07  1.414495e+13  1.833351e+14   \n",
       "\n",
       "                     HumidityRatio  Occupancy  \n",
       "date                                           \n",
       "2015-02-04 17:51:00   4.792988e-03        1.0  \n",
       "2015-02-04 17:51:59   2.292698e-05        1.0  \n",
       "2015-02-04 17:53:00   1.095786e-07        1.0  \n",
       "2015-02-04 17:54:00   5.228555e-10        1.0  \n",
       "2015-02-04 17:55:00   2.487220e-12        1.0  "
      ]
     },
     "execution_count": 166,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.cumprod().head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 6. Метод apply"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {},
   "outputs": [],
   "source": [
    "def scaling(df):\n",
    "    return (df - df.mean()) / df.std()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>2.518315</td>\n",
       "      <td>0.278509</td>\n",
       "      <td>1.573666</td>\n",
       "      <td>0.364926</td>\n",
       "      <td>1.091690</td>\n",
       "      <td>1.925929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>2.488814</td>\n",
       "      <td>0.277696</td>\n",
       "      <td>1.591637</td>\n",
       "      <td>0.341860</td>\n",
       "      <td>1.080489</td>\n",
       "      <td>1.925929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>2.488814</td>\n",
       "      <td>0.273628</td>\n",
       "      <td>1.573666</td>\n",
       "      <td>0.340269</td>\n",
       "      <td>1.075822</td>\n",
       "      <td>1.925929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>2.488814</td>\n",
       "      <td>0.265492</td>\n",
       "      <td>1.573666</td>\n",
       "      <td>0.323567</td>\n",
       "      <td>1.066489</td>\n",
       "      <td>1.925929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>2.439646</td>\n",
       "      <td>0.265492</td>\n",
       "      <td>1.573666</td>\n",
       "      <td>0.311636</td>\n",
       "      <td>1.049458</td>\n",
       "      <td>1.925929</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity     Light       CO2  HumidityRatio  \\\n",
       "date                                                                            \n",
       "2015-02-04 17:51:00     2.518315  0.278509  1.573666  0.364926       1.091690   \n",
       "2015-02-04 17:51:59     2.488814  0.277696  1.591637  0.341860       1.080489   \n",
       "2015-02-04 17:53:00     2.488814  0.273628  1.573666  0.340269       1.075822   \n",
       "2015-02-04 17:54:00     2.488814  0.265492  1.573666  0.323567       1.066489   \n",
       "2015-02-04 17:55:00     2.439646  0.265492  1.573666  0.311636       1.049458   \n",
       "\n",
       "                     Occupancy  \n",
       "date                            \n",
       "2015-02-04 17:51:00   1.925929  \n",
       "2015-02-04 17:51:59   1.925929  \n",
       "2015-02-04 17:53:00   1.925929  \n",
       "2015-02-04 17:54:00   1.925929  \n",
       "2015-02-04 17:55:00   1.925929  "
      ]
     },
     "execution_count": 170,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.apply(scaling).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 171,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Temperature       20.619084\n",
       "Humidity          25.731507\n",
       "Light            119.519375\n",
       "CO2              606.546243\n",
       "HumidityRatio      0.003863\n",
       "Occupancy          0.212330\n",
       "dtype: float64"
      ]
     },
     "execution_count": 171,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.apply('mean')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7. lambda функции и метод agg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "      <th>Light</th>\n",
       "      <th>CO2</th>\n",
       "      <th>HumidityRatio</th>\n",
       "      <th>Occupancy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>sum</th>\n",
       "      <td>167901.198083</td>\n",
       "      <td>209531.663833</td>\n",
       "      <td>973246.266667</td>\n",
       "      <td>4.939106e+06</td>\n",
       "      <td>31.452392</td>\n",
       "      <td>1729.00000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>&lt;lambda&gt;</th>\n",
       "      <td>20.619084</td>\n",
       "      <td>25.731507</td>\n",
       "      <td>119.519375</td>\n",
       "      <td>6.065462e+02</td>\n",
       "      <td>0.003863</td>\n",
       "      <td>0.21233</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Temperature       Humidity          Light           CO2  \\\n",
       "sum       167901.198083  209531.663833  973246.266667  4.939106e+06   \n",
       "<lambda>      20.619084      25.731507     119.519375  6.065462e+02   \n",
       "\n",
       "          HumidityRatio   Occupancy  \n",
       "sum           31.452392  1729.00000  \n",
       "<lambda>       0.003863     0.21233  "
      ]
     },
     "execution_count": 177,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.agg(['sum', lambda x: x.mean()])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5. Работа с текстовыми данными\n",
    "\n",
    "Вернемся к табличке из примера с Join:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>subject_id</th>\n",
       "      <th>course_name</th>\n",
       "      <th>description</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100500</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>200600</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>300700</td>\n",
       "      <td>Анализ данных</td>\n",
       "      <td>краткий курс для чайников</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>400700</td>\n",
       "      <td>Мат. анализ</td>\n",
       "      <td>многомерный анализ</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  subject_id       course_name                                   description\n",
       "0     100500        Математика  продвинутые методы математической статистики\n",
       "1     200600  Программирование                       расширенный курс по с++\n",
       "2     300700     Анализ данных                     краткий курс для чайников\n",
       "3     400700       Мат. анализ                            многомерный анализ"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_2 = np.array([['100500', '200600', '300700', '400700'],\n",
    "                   ['Математика', 'Программирование', 'Анализ данных', 'Мат. анализ'], \n",
    "                   ['продвинутые методы математической статистики', 'расширенный курс по с++',\\\n",
    "                            'краткий курс для чайников', 'многомерный анализ']])\n",
    "subjects = pd.DataFrame(data_2.T, columns = ['subject_id','course_name', 'description'])\n",
    "subjects"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    [продвинутые, методы, математической, статистики]\n",
       "1                         [расширенный, курс, по, с++]\n",
       "2                       [краткий, курс, для, чайников]\n",
       "3                                [многомерный, анализ]\n",
       "Name: description, dtype: object"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subjects.description.str.split(' ')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    ПРОДВИНУТЫЕ МЕТОДЫ МАТЕМАТИЧЕСКОЙ СТАТИСТИКИ\n",
       "1                         РАСШИРЕННЫЙ КУРС ПО С++\n",
       "2                       КРАТКИЙ КУРС ДЛЯ ЧАЙНИКОВ\n",
       "3                              МНОГОМЕРНЫЙ АНАЛИЗ\n",
       "Name: description, dtype: object"
      ]
     },
     "execution_count": 188,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subjects.description.str.upper()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 189,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    44\n",
       "1    23\n",
       "2    25\n",
       "3    18\n",
       "Name: description, dtype: int64"
      ]
     },
     "execution_count": 189,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subjects.description.str.len()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 197,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    продвинутые методы математической статистики\n",
       "1                           расширенный курс по с\n",
       "2                       краткий курс для чайников\n",
       "3                              многомерный анализ\n",
       "Name: description, dtype: object"
      ]
     },
     "execution_count": 197,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subjects.description.str.strip('+')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 199,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    продвинутые методы м@тем@тической ст@тистики\n",
       "1                         р@сширенный курс по с++\n",
       "2                       кр@ткий курс для ч@йников\n",
       "3                              многомерный @н@лиз\n",
       "Name: description, dtype: object"
      ]
     },
     "execution_count": 199,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subjects.description.str.replace(\"а\", \"@\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 205,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    методы\n",
       "1      курс\n",
       "2      курс\n",
       "3    анализ\n",
       "Name: description, dtype: object"
      ]
     },
     "execution_count": 205,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subjects.description.str.split(' ').str.get(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>продвинутые</td>\n",
       "      <td>методы</td>\n",
       "      <td>математической</td>\n",
       "      <td>статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>расширенный</td>\n",
       "      <td>курс</td>\n",
       "      <td>по</td>\n",
       "      <td>с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>краткий</td>\n",
       "      <td>курс</td>\n",
       "      <td>для</td>\n",
       "      <td>чайников</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>многомерный</td>\n",
       "      <td>анализ</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             0       1               2           3\n",
       "0  продвинутые  методы  математической  статистики\n",
       "1  расширенный    курс              по         с++\n",
       "2      краткий    курс             для    чайников\n",
       "3  многомерный  анализ            None        None"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = subjects.description.str.split(' ', expand=True)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>subject_id</th>\n",
       "      <th>course_name</th>\n",
       "      <th>description</th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100500</td>\n",
       "      <td>Математика</td>\n",
       "      <td>продвинутые методы математической статистики</td>\n",
       "      <td>продвинутые</td>\n",
       "      <td>методы</td>\n",
       "      <td>математической</td>\n",
       "      <td>статистики</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>200600</td>\n",
       "      <td>Программирование</td>\n",
       "      <td>расширенный курс по с++</td>\n",
       "      <td>расширенный</td>\n",
       "      <td>курс</td>\n",
       "      <td>по</td>\n",
       "      <td>с++</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>300700</td>\n",
       "      <td>Анализ данных</td>\n",
       "      <td>краткий курс для чайников</td>\n",
       "      <td>краткий</td>\n",
       "      <td>курс</td>\n",
       "      <td>для</td>\n",
       "      <td>чайников</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>400700</td>\n",
       "      <td>Мат. анализ</td>\n",
       "      <td>многомерный анализ</td>\n",
       "      <td>многомерный</td>\n",
       "      <td>анализ</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  subject_id       course_name                                   description  \\\n",
       "0     100500        Математика  продвинутые методы математической статистики   \n",
       "1     200600  Программирование                       расширенный курс по с++   \n",
       "2     300700     Анализ данных                     краткий курс для чайников   \n",
       "3     400700       Мат. анализ                            многомерный анализ   \n",
       "\n",
       "             0       1               2           3  \n",
       "0  продвинутые  методы  математической  статистики  \n",
       "1  расширенный    курс              по         с++  \n",
       "2      краткий    курс             для    чайников  \n",
       "3  многомерный  анализ            None        None  "
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([subjects, df], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Temperature</th>\n",
       "      <th>Humidity</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:51:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:53:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:54:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:55:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:57:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:57:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 17:58:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:00:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:01:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:02:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:03:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:04:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:04:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:06:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:07:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:08:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.2900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:08:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.3900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:10:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.3900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:10:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.3900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:11:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.3900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:13:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.4450</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:14:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.5000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:15:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.5000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:16:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.5000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:16:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.5000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:17:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.5000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:19:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.5000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-04 18:20:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>27.5000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:04:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:04:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:06:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:07:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:08:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:08:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:10:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:10:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:11:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:13:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:14:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:15:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:16:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:16:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:17:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:19:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:20:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:21:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:22:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:23:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:23:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:24:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:26:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:27:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:28:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:29:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:29:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:30:59</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:32:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-10 09:33:00</th>\n",
       "      <td>23.18</td>\n",
       "      <td>39.1175</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8143 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Temperature  Humidity\n",
       "date                                      \n",
       "2015-02-04 17:51:00        23.18   27.2720\n",
       "2015-02-04 17:51:59        23.18   27.2720\n",
       "2015-02-04 17:53:00        23.18   27.2720\n",
       "2015-02-04 17:54:00        23.18   27.2720\n",
       "2015-02-04 17:55:00        23.18   27.2720\n",
       "2015-02-04 17:55:59        23.18   27.2720\n",
       "2015-02-04 17:57:00        23.18   27.2720\n",
       "2015-02-04 17:57:59        23.18   27.2720\n",
       "2015-02-04 17:58:59        23.18   27.2720\n",
       "2015-02-04 18:00:00        23.18   27.2720\n",
       "2015-02-04 18:01:00        23.18   27.2720\n",
       "2015-02-04 18:02:00        23.18   27.2720\n",
       "2015-02-04 18:03:00        23.18   27.2720\n",
       "2015-02-04 18:04:00        23.18   27.2720\n",
       "2015-02-04 18:04:59        23.18   27.2720\n",
       "2015-02-04 18:06:00        23.18   27.2720\n",
       "2015-02-04 18:07:00        23.18   27.2720\n",
       "2015-02-04 18:08:00        23.18   27.2900\n",
       "2015-02-04 18:08:59        23.18   27.3900\n",
       "2015-02-04 18:10:00        23.18   27.3900\n",
       "2015-02-04 18:10:59        23.18   27.3900\n",
       "2015-02-04 18:11:59        23.18   27.3900\n",
       "2015-02-04 18:13:00        23.18   27.4450\n",
       "2015-02-04 18:14:00        23.18   27.5000\n",
       "2015-02-04 18:15:00        23.18   27.5000\n",
       "2015-02-04 18:16:00        23.18   27.5000\n",
       "2015-02-04 18:16:59        23.18   27.5000\n",
       "2015-02-04 18:17:59        23.18   27.5000\n",
       "2015-02-04 18:19:00        23.18   27.5000\n",
       "2015-02-04 18:20:00        23.18   27.5000\n",
       "...                          ...       ...\n",
       "2015-02-10 09:04:00        23.18   39.1175\n",
       "2015-02-10 09:04:59        23.18   39.1175\n",
       "2015-02-10 09:06:00        23.18   39.1175\n",
       "2015-02-10 09:07:00        23.18   39.1175\n",
       "2015-02-10 09:08:00        23.18   39.1175\n",
       "2015-02-10 09:08:59        23.18   39.1175\n",
       "2015-02-10 09:10:00        23.18   39.1175\n",
       "2015-02-10 09:10:59        23.18   39.1175\n",
       "2015-02-10 09:11:59        23.18   39.1175\n",
       "2015-02-10 09:13:00        23.18   39.1175\n",
       "2015-02-10 09:14:00        23.18   39.1175\n",
       "2015-02-10 09:15:00        23.18   39.1175\n",
       "2015-02-10 09:16:00        23.18   39.1175\n",
       "2015-02-10 09:16:59        23.18   39.1175\n",
       "2015-02-10 09:17:59        23.18   39.1175\n",
       "2015-02-10 09:19:00        23.18   39.1175\n",
       "2015-02-10 09:20:00        23.18   39.1175\n",
       "2015-02-10 09:21:00        23.18   39.1175\n",
       "2015-02-10 09:22:00        23.18   39.1175\n",
       "2015-02-10 09:23:00        23.18   39.1175\n",
       "2015-02-10 09:23:59        23.18   39.1175\n",
       "2015-02-10 09:24:59        23.18   39.1175\n",
       "2015-02-10 09:26:00        23.18   39.1175\n",
       "2015-02-10 09:27:00        23.18   39.1175\n",
       "2015-02-10 09:28:00        23.18   39.1175\n",
       "2015-02-10 09:29:00        23.18   39.1175\n",
       "2015-02-10 09:29:59        23.18   39.1175\n",
       "2015-02-10 09:30:59        23.18   39.1175\n",
       "2015-02-10 09:32:00        23.18   39.1175\n",
       "2015-02-10 09:33:00        23.18   39.1175\n",
       "\n",
       "[8143 rows x 2 columns]"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[['Temperature', 'Humidity']].cummax()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
